在fastreport中打印空白表格及小写金额转大写金额

delphi component 专栏收录该内容
67 篇文章 0 订阅

在fastreport中的code脚本中写如下代码:

 

var 
  PageLine: integer;       //在現在頁列印到第幾行 
  PageMaxRow: integer=15;  //設定每頁列數
  C_ToTal, C_JINE : STring;
  ToTal_Debit, Page_JinE, Total_Credit : Extended;  //Debit-借方 ,credit-贷方                                                   
  aString : Array [0..9] of String;
function GETDXRMB(money:string):string;
var
  i,j:integer;
  Numcount,Dotcount,stemp,stemp1,stemp2,sFinal:string;
begin
  aString[0]:= '零';     aString[1]:= '壹';
  aString[2]:= '贰';     aString[3]:= '叁';
  aString[4]:= '肆';     aString[5]:= '伍';
  aString[6]:= '陆';     aString[7]:= '柒';
  aString[8]:= '捌';     aString[9]:= '玖';
  Numcount:=money;
  Dotcount := '';
  stemp := '';
  stemp1 := '';
  stemp2 := '';
  sFinal := '';
  i:=pos('.',Numcount);
  if i<>0 then
  begin
    Dotcount:=copy(Numcount,i+1,length(Numcount)-1);
    numcount:=copy(numcount,1,i-1);
    if (dotcount<>'00')and (dotcount<>'0') then
    begin
      if (length(dotcount)=2) and (strtoint(copy(dotcount,2,1))<>0) then
        Dotcount:= aString[strtoint(copy(Dotcount, 1, 1))]+'角'+aString[strtoint(copy(Dotcount, 2, 1))]+'分'
      else
        Dotcount:= aString[strtoint(copy(Dotcount, 1, 1))]+'角'
    end
    else
     dotcount:='';
  end;

  if length(numcount)> 8 then stemp:=copy(numcount,1,length(numcount)-8);//亿
  if (stemp<>'') and (strtoint(stemp)>0) then sFinal:=sFinal+GetNumstring(strtoint(stemp))+'亿';

  if Length(Numcount) > 4 then sTemp:= copy(Numcount,1,length(numcount)-4); //万
  if (sTemp <> '') and (strtoint(sTemp) <> 0) Then sFinal:= sFinal+ GetNumString(strtoint(sTemp))+'万';
  sFinal:= sFinal + GetNumString(strtoInt(copy(Numcount,1,length(numcount))));
  sTemp:='';
  j:=Length(sFinal);
  i:=1;
  while i<j do
  begin
    sTemp1:=copy(sFinal,i,2);
    if i<j then sTemp2:=copy(sFinal,i+2,2);
    if sTemp1<>'零' Then sTemp:= sTemp + sTemp1
    else if (sTemp<>'') and (sTemp1='零') and (sTemp2<>'万') and (sTemp2<>'亿') and (sTemp2<>'零') and (sTemp2<>'') and (i<>1) and (i<Length(sFinal)) then sTemp:=sTemp+sTemp1;
    i:=i+2;
  end;

  sFinal:= sTemp + '元';
  if Dotcount <> '' Then
    sFinal:=sFinal+Dotcount
  else
    sFinal:=sFinal+'整';
  Result :=sFinal;
end;

function getNumstring(inum:integer):string;
var
  i:integer;
  s1temp,stemp,sreturn:string;
begin
  aString[0]:='零';aString[1]:='壹';
  aString[2]:='贰';aString[3]:='叁';
  aString[4]:='肆';aString[5]:='伍';
  aString[6]:='陆';aString[7]:='柒';
  aString[8]:='捌';aString[9]:='玖';
  s1temp := '';
  stemp := '';
  sreturn := '';
  s1temp:='0000'+inttostr(iNum);
  sTemp:=copy(s1temp,length(inttostr(inum))+1,4);
  for i:=1 To 4 do
  begin
    if copy(sTemp,i,1) = '0' Then
    begin
      sReturn:= sReturn+'零';
    end
    else
    begin
      sReturn:=sReturn+aString[strtoInt(copy(sTemp,i,1))];
      case i of
        1: sReturn:= sReturn+'仟';
        2: sReturn:= sReturn+'佰';
        3: sReturn:= sReturn+'拾';
      end;
    end;
  end;
  Result:=sReturn;
end;
     
 
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
 PageLine := <Line> mod PageMaxRow; 
  if (PageLine = 1) and (<line> > 1) then   
    Engine.newpage;
  child1.visible := False; 
end;

procedure Footer1OnBeforePrint(Sender: TfrxComponent);
var i:integer;                              
begin
  i := iif(PageLine=0, PageMaxRow, PageLine); 
  child1.visible := True;
  while i < PageMaxRow do
  begin   
    i := i + 1;
   Engine.ShowBand(Child1);  //印空白表格
             
  end;
  child1.visible := False;
   
  PageFooter1.Visible:=False;

  C_JinE := GETDXRMB(FloatToStr(Page_JinE));
  C_ToTal := GETDXRMB(FloatToStr(Total_Debit));

  Memo10.Text:=C_Total;
  Memo36.Text:=FormatFloat('#0.00',Total_Debit);
  Memo4.Text:=FormatFloat('#0.00',Total_Credit);                               
   
  PageFooter1.Height:=0;                                               
end;

procedure PageFooter1OnAfterPrint(Sender: TfrxComponent);
begin
  Page_JinE := 0; 
end;

procedure MasterData1OnAfterPrint(Sender: TfrxComponent);
begin
  Page_JinE := Page_JinE + <frxDB_Detail."DEBITS_MONEY">;
  Total_Debit := Total_Debit + <frxDB_Detail."DEBITS_MONEY">;
  Total_Credit := Total_Credit + <frxDB_Detail."Credits_MONEY">;                                                                             
end;

procedure PageFooter1OnBeforePrint(Sender: TfrxComponent);
begin
  C_JinE := GETDXRMB(FloatToStr(Page_JinE)); 
end;

begin

end.
————————————————
版权声明:本文为CSDN博主「9807146wang」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/9807146wang/article/details/40185137

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 扫一扫,分享海报

©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值