在水晶报表里如何实现  金额从数字转换成大写的汉字(壹,贰....)      
还有就是在报表里  为什么  数字为小数的  只显示  小数点后面的?  如(0.7    显示为  .7)    谢谢了,

解决方案 »

  1.   

    又转换的程序
    public static void FloatTransform(string strNum,ref string result)
    {
    string strInt;
    string strFloat;
    strInt=strNum.Substring(0,strNum.IndexOf(".",0));//整数部分的值
    strFloat=strNum.Substring((strNum.IndexOf(".",0)+1),(strNum.Length-strNum.IndexOf(".",0)-1));//小数部分的值
    //MessageBox.Show(strInt);
    //MessageBox.Show(strFloat);
    //return;
    int numLen=strInt.Length;
    string dx="零壹贰叁肆伍陆柒捌玖";
    string ws="分角元拾佰仟万拾佰仟亿拾佰仟";
    //MessageBox.Show(ws.Length.ToString());
    result=null;
    int i=0,w=0;
    int q=0;
    bool ling=true;
    //计算整数的大写!
    while(i<numLen)
    {
    if(strInt.Substring(i,1)!="0")
    {
    //MessageBox.Show(strNum.Substring(i,1));
    result=result+dx.Substring(Convert.ToInt32(strInt.Substring(i,1)),1);
    result=result+ws.Substring((numLen-i)+1,1);
    ling=false;
    i++;
    }
    else if(ling==false&&strInt.Substring(i,1)=="0")
    {
    if((numLen-i+1)>10)//判断是否过亿
    {
    w=0;
    for(q=11;q<(numLen-i+1);q++)
    {
    w=w+Convert.ToInt32(strInt.Substring(numLen-q+1,1));
    }
    if(w==0)
    {
    result=result+"亿";
    i=numLen-9;
    }
    else
    {
    result=result+"零";
    i=i+1;
    ling=true;
    }
    }
    else if((numLen-i+1)>6)//判断是否是万以上
    {
    w=0;
    for(q=1;q<(numLen-i+1);q++)
    {
    w=w+Convert.ToInt32(strInt.Substring(numLen-q,1));
    }
    if(w==0)
    {
    result=result+"整";
    i=numLen+1;
    }
    else
    {
    result=result+"零";
    i=i+1;
    ling=true;
    }
    } else if((numLen-i+1)>3)
    {
    w=0;
    for(q=1;q<(numLen-i+1);q++)
    {
    w=w+Convert.ToInt32(strInt.Substring(numLen-q,1));
    }
    if(w==0)
    {
    result=result+"整";
    i=numLen+1;
    }
    else
    {
    result=result+"零";
    i=i+1;
    ling=true;
    }
    }
    else if((numLen-i+1)>0)
    {
    w=0;
    for(q=1;q<(numLen-i+1);q++)
    {
    w=w+Convert.ToInt32(strInt.Substring(numLen-q,1));
    }
    if(w==0)
    {
    result=result+"整";
    i=numLen+1;
    }
    else
    {
    result=result+"零";
    i=i+1;
    ling=true;
    }
    }
    }
    else if(strInt.Substring(i,1)=="0"&&ling==true)
    {
    i=i+1;
    } }
    //计算小数部分的大写!

    int numLenFlt=strFloat.Length;
    if(strFloat.Substring(0,1)=="0"&&strFloat.Substring(1,1)=="0")
    {
    result=result+"整";
    }
    else if(strFloat.Substring(0,1)!="0"&&strFloat.Substring(1,1)=="0")
    {
    result=result+dx.Substring(Convert.ToInt32(strFloat.Substring(0,1)),1)+"角";
    }
    else if(strFloat.Substring(0,1)=="0"&&strFloat.Substring(1,1)!="0")
    {
    result=result+dx.Substring(Convert.ToInt32(strFloat.Substring(1,1)),1)+"分";
    }
    else if(strFloat.Substring(0,1)!="0"&&strFloat.Substring(1,1)!="0")
    {
    result=result+dx.Substring(Convert.ToInt32(strFloat.Substring(0,1)),1)+"角"+dx.Substring(Convert.ToInt32(strFloat.Substring(1,1)),1)+"分";
    }

    }
      

  2.   

    调用方法Text2 = ChMoney(Val(Text1))
    名称: CCh
    得到一位数字 N1 的汉字大写
    0 返回 ""
    Private Function CCh(N1) As String
    Select Case N1
    Case 0
    CCh = "零"
    Case 1
    CCh = "壹"
    Case 2
    CCh = "贰"
    Case 3
    CCh = "叁"
    Case 4
    CCh = "肆"
    Case 5
    CCh = "伍"
    Case 6
    CCh = "陆"
    Case 7
    CCh = "柒"
    Case 8
    CCh = "捌"
    Case 9
    CCh = "玖"
    End Select
    End Function
    名称: ChMoney
    得到数字 N1 的汉字大写
    最大为 千万位
    O 返回 ""
    Public Function ChMoney(N1) As String
    Dim tMoney As String
    Dim lMoney As String
    Dim tn 小数位置
    Dim s1 As String 临时STRING 小数部分
    Dim s2 As String 1000 以内
    Dim s3 As String 10000
    If N1 = 0 Then
    ChMoney = " "
    Exit Function
    End If
    If N1 < 0 Then
    ChMoney = "负" + ChMoney(Abs(N1))
    Exit Function
    End If
    tMoney = Trim(Str(N1))
    tn = InStr(tMoney, ".") 小数位置
    s1 = ""
    If tn <> 0 Then
    ST1 = Right(tMoney, Len(tMoney) - tn)
    If ST1 <> "" Then
    t1 = Left(ST1, 1)
    ST1 = Right(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s1 = s1 + CCh(Val(t1)) + "角"
    End If
    If ST1 <> "" Then
    t1 = Left(ST1, 1)
    s1 = s1 + CCh(Val(t1)) + "分"
    End If
    End If
    ST1 = Left(tMoney, tn - 1)
    Else
    ST1 = tMoney
    End If
    s2 = ""
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    s2 = CCh(Val(t1)) + s2
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s2 = CCh(Val(t1)) + "拾" + s2
    Else
    If Left(s2, 1) <> "零" Then s2 = "零" + s2
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s2 = CCh(Val(t1)) + "佰" + s2
    Else
    If Left(s2, 1) <> "零" Then s2 = "零" + s2
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s2 = CCh(Val(t1)) + "仟" + s2
    Else
    If Left(s2, 1) <> "零" Then s2 = "零" + s2
    End If
    End If
    s3 = ""
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    s3 = CCh(Val(t1)) + s3
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s3 = CCh(Val(t1)) + "拾" + s3
    Else
    If Left(s3, 1) <> "零" Then s3 = "零" + s3
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s3 = CCh(Val(t1)) + "佰" + s3
    Else
    If Left(s3, 1) <> "零" Then s3 = "零" + s3
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s3 = CCh(Val(t1)) + "仟" + s3
    End If
    End If
    If Right(s2, 1) = "零" Then s2 = Left(s2, Len(s2) - 1)
    If Len(s3) > 0 Then
    If Right(s3, 1) = "零" Then s3 = Left(s3, Len(s3) - 1)
    s3 = s3 & "万"
    End If
    ChMoney = IIf(s3 & s2 = "", s1, s3 & s2 & "元" & s1)
    End Function
    调用方法Text2 = ChMoney(Val(Text1))
    名称: CCh
    得到一位数字 N1 的汉字大写
    0 返回 ""
    Private Function CCh(N1) As String
    Select Case N1
    Case 0
    CCh = "零"
    Case 1
    CCh = "壹"
    Case 2
    CCh = "贰"
    Case 3
    CCh = "叁"
    Case 4
    CCh = "肆"
    Case 5
    CCh = "伍"
    Case 6
    CCh = "陆"
    Case 7
    CCh = "柒"
    Case 8
    CCh = "捌"
    Case 9
    CCh = "玖"
    End Select
    End Function
    名称: ChMoney
    得到数字 N1 的汉字大写
    最大为 千万位
    O 返回 ""
    Public Function ChMoney(N1) As String
    Dim tMoney As String
    Dim lMoney As String
    Dim tn 小数位置
    Dim s1 As String 临时STRING 小数部分
    Dim s2 As String 1000 以内
    Dim s3 As String 10000
    If N1 = 0 Then
    ChMoney = " "
    Exit Function
    End If
    If N1 < 0 Then
    ChMoney = "负" + ChMoney(Abs(N1))
    Exit Function
    End If
    tMoney = Trim(Str(N1))
    tn = InStr(tMoney, ".") 小数位置
    s1 = ""
    If tn <> 0 Then
    ST1 = Right(tMoney, Len(tMoney) - tn)
    If ST1 <> "" Then
    t1 = Left(ST1, 1)
    ST1 = Right(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s1 = s1 + CCh(Val(t1)) + "角"
    End If
    If ST1 <> "" Then
    t1 = Left(ST1, 1)
    s1 = s1 + CCh(Val(t1)) + "分"
    End If
    End If
    ST1 = Left(tMoney, tn - 1)
    Else
    ST1 = tMoney
    End If
    s2 = ""
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    s2 = CCh(Val(t1)) + s2
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s2 = CCh(Val(t1)) + "拾" + s2
    Else
    If Left(s2, 1) <> "零" Then s2 = "零" + s2
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s2 = CCh(Val(t1)) + "佰" + s2
    Else
    If Left(s2, 1) <> "零" Then s2 = "零" + s2
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s2 = CCh(Val(t1)) + "仟" + s2
    Else
    If Left(s2, 1) <> "零" Then s2 = "零" + s2
    End If
    End If
    s3 = ""
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    s3 = CCh(Val(t1)) + s3
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s3 = CCh(Val(t1)) + "拾" + s3
    Else
    If Left(s3, 1) <> "零" Then s3 = "零" + s3
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s3 = CCh(Val(t1)) + "佰" + s3
    Else
    If Left(s3, 1) <> "零" Then s3 = "零" + s3
    End If
    End If
    If ST1 <> "" Then
    t1 = Right(ST1, 1)
    ST1 = Left(ST1, Len(ST1) - 1)
    If t1 <> "0" Then
    s3 = CCh(Val(t1)) + "仟" + s3
    End If
    End If
    If Right(s2, 1) = "零" Then s2 = Left(s2, Len(s2) - 1)
    If Len(s3) > 0 Then
    If Right(s3, 1) = "零" Then s3 = Left(s3, Len(s3) - 1)
    s3 = s3 & "万"
    End If
    ChMoney = IIf(s3 & s2 = "", s1, s3 & s2 & "元" & s1)
    End Function
      

  3.   

    http://community.csdn.net/Expert/topic/3205/3205297.xml?temp=6.699771E-02
    只需要设置需要大写的字段就可以了