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

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.

• 本文已收录于以下专栏：

举报原因： 您举报文章：在fastreport中打印空白表格及小写金额转大写金额 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)