zoukankan      html  css  js  c++  java
  • FastReport 金额大小写转换自定义函数

    在FastReport中编写金额数字转换大写自定义函数

    function MoneyToCharacter(Money:real):string; //数字转换为中文大写
    var
    temp:string;
    resu:string;
    i,j:integer;
    len:integer;
    Num:array[0..9] of string;
    A:array[0..13] of string;
    begin
    Num[0]:='零';
    num[1]:='壹';
    Num[2]:='贰';
    num[3]:='叁';
    Num[4]:='肆';
    num[5]:='伍';
    Num[6]:='陆';
    num[7]:='柒';
    Num[8]:='捌';
    num[9]:='玖';
    a[0]:='分';
    a[1]:='角';
    a[2]:='元';
    a[3]:='拾';
    a[4]:='佰';
    a[5]:='仟';
    a[6]:='万';
    a[7]:='拾';
    a[8]:='佰';
    a[9]:='仟';
    a[10]:='亿';
    a[11]:='拾';
    a[12]:='佰';
    a[13]:='仟';
    temp:=trim(inttostr(round(money*100)));
    len:=length(temp);
    resu:='';
    if (len>13) or (len=0) then
    begin
    exit;
    end;
    for i:=1 to len do
    begin
    j:=strtoint(copy(temp,i,1));
    resu:=resu+num[j]+a[len-i];
    end;
    len:=length(resu);
    result:=copy(resu,0,len-8);
    end;

    四舍五入,取整数

    调用函数

    procedure Memo41OnAfterData(Sender: TfrxComponent);
    begin
    memo41.text:='总金额(大写):'+MoneyToCharacter(Round(SUM(<加工."发货金额">,MasterData1)))+'整';
    TfrxMemoView(Sender).Font.Size:=12;
    while ((TfrxMemoView(Sender).CalcHeight-TfrxMemoView(Sender).LineSpacing)-TfrxMemoView(Sender).Height>0) do
    begin
    TfrxMemoView(Sender).Font.Size := TfrxMemoView(Sender).Font.Size-1;
    end;
    end;

    如下显示:

    显示浮点数属性设置 displayFormat Formatstr %2.2n
    ————————————————
    版权声明:本文为CSDN博主「心梦缘-雪雁」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/mxy906975387/article/details/93861312

  • 相关阅读:
    mysql批量导入删除
    sql查重去除id最小值
    Rest构建分布式 SpringCloud微服务架构项目
    Django模板语言及视图
    Django模板语言
    面向对象进阶
    初识面向对象
    os模块和sys模块
    random模
    时间模块
  • 原文地址:https://www.cnblogs.com/approx/p/15544420.html
Copyright © 2011-2022 走看看