我现在用fastreport做打印报表,请问怎么把合计数据变成中文大写!!谢谢!!]产品    数量   单价   总价格
产品1   30    10     300
产品2   9     7      63
产品3   20    50     1000合计    59    价格合计¥1363  大写:壹仟叁佰陆拾叁元  请问怎么转换成 价格合计¥1363  大写:壹仟叁佰陆拾叁元 这种格式!!!!

解决方案 »

  1.   

    表中加一个字段,用于存大写描述的!
    Function NtoC( n0 :Extended) :wideString;
      Function IIF(b :boolean; s1,s2 :string):string;
        begin
          if b then IIF:=s1 else IIF:=s2;
        end;
      Const c:WideString = '零壹贰叁肆伍陆柒捌玖◇分角元拾佰仟万拾佰仟亿拾佰仟万';
      var L,i,n :integer;
          Z,a :boolean;
          s, st :WideString;
    begin
      if trim(floattostr(n0))='' then result:='无';
      s:= FormatFloat('0',n0*100);
      L:= Length(s);
      Z:= false;
      For i:=1 to L do
        begin
        n:= ord( s[L-i+1])-48;// StrToInt( s[L-i+1]);
        a:= (i=11)or(i=7)or(i=3)or(i=1);
        st:=IIF((n=0)and(Z or a), '', c[n+1])
          + IIF((n=0)and(i=1),'整',
            IIF((n>0)or a, c[i+11], ''))
          + IIF((n=0)and(not Z)and(i>1)and a,'零','')
          + st;
        Z:= n=0;
        end;
      For i:=1 To Length(st) do
        If Copy(st,i,2)='亿万' Then Delete(st,i+1,1);
      result:= IIF(n0>9999999999999.99, '溢出', IIf(n0 = 0, '零', st));
    End;