可是FastReport生成的报表读取memo时总得到的是"设计内容" if view.Name ='Memo25' then view.Memo.Text:=changeMoney(aaa);其中aaa为FastReport中小写合计值
设计报表的时候有上下两个输入框,上面的直接输入“设计内容”,下面还有一个是用来写程序的,里面写了一个 begin
end在其中写程序就行了,不要在Delphi的代码中写。
把你的金额小写到大写的函数贴出来,我帮你改成FastReport设计器中的代码!
我已经自定义了一个函数 function changeMoney(TM:real):string ; //金额转换 var shu:array of string[2]; shu1:array of string[2]; shuzi,zifu:string;temp1:integer; begin setlength(shu,10);setlength(shu1,10); shu[9]:='仟';shu[8]:='佰';shu[7]:='拾';shu[6]:='万'; shu[5]:='仟';shu[4]:='伯';shu[3]:='拾';shu[2]:='圆'; shu[1]:='角';shu[0]:='分'; shu1[0]:='零';shu1[1]:='壹';shu1[2]:='贰'; shu1[3]:='叁';shu1[4]:='肆';shu1[5]:='伍'; shu1[6]:='陆';shu1[7]:='柒';shu1[8]:='捌'; shu1[9]:='玖'; shuzi:=inttostr(round(tm*100)); if tm>99999999.99 then result:='数据溢出,错误' else begin zifu:=''; temp1:=1; while temp1<=length(shuzi) do begin if copy(shuzi,temp1,1)<>'0' then begin if copy(shuzi,temp1-1,1)='0' then zifu:=zifu+shu1[0]; zifu:=zifu+shu1[strtoint(copy(shuzi,temp1,1))]+shu[length(shuzi)-temp1]; end; if copy(shuzi,temp1,1)='0' then begin if temp1=length(shuzi)-2 then zifu:=zifu+shu[2]; if temp1=length(shuzi)-6 then zifu:=zifu+shu[6]; end; temp1:=temp1+1 end; result:=zifu; end; end;
begin shu[9]:='仟';shu[8]:='佰';shu[7]:='拾';shu[6]:='万'; shu[5]:='仟';shu[4]:='伯';shu[3]:='拾';shu[2]:='圆'; shu[1]:='角';shu[0]:='分'; shu1[0]:='零';shu1[1]:='壹';shu1[2]:='贰'; shu1[3]:='叁';shu1[4]:='肆';shu1[5]:='伍'; shu1[6]:='陆';shu1[7]:='柒';shu1[8]:='捌'; shu1[9]:='玖'; shuzi:=[STR(ROUND([SUM([ADOTable1."金额"])]* 100))]; if [SUM([ADOTable1."金额"]>99999999.99 then result:='数据溢出,错误' else begin zifu:=''; temp1:=1; while temp1<=length(shuzi) do begin if copy(shuzi,temp1,1)<>'0' then begin if copy(shuzi,temp1-1,1)='0' then zifu:=zifu+shu1[0]; zifu:=zifu+shu1[[INT(copy(shuzi,temp1,1))]]+shu[length(shuzi)-temp1]; end; if copy(shuzi,temp1,1)='0' then begin if temp1=length(shuzi)-2 then zifu:=zifu+shu[2]; if temp1=length(shuzi)-6 then zifu:=zifu+shu[6]; end; temp1:=temp1+1 end; result:=zifu; end; memo.clear; memo.add(result); end
前面的两段可以也应该改为 shu := '分角圆拾伯仟万拾佰仟'; shu1 := '零壹贰叁肆伍陆柒捌玖';Delphi中的函数也应该写成 var shu, shu1: string; begin shu := '分角圆拾伯仟万拾佰仟'; shu1 := '零壹贰叁肆伍陆柒捌玖';
ADOTable1."金额" ,改为你的那个金额字段 ///////////////////////////////////////////////// 可是FastReport生成的报表读取memo时总得到的是"设计内容" if view.Name ='Memo25' then view.Memo.Text:=changeMoney(aaa);其中aaa为FastReport中小写合计值 //////////////////////////////////////////////////// 在报表设计器中双击你的那个“Memo25”,在弹出的对话框的下面部分的begin和end中间加上面的代码,我这边已经做出来了才回的贴!
写法均可,Delphi把字符串认为数组. 现在我可以详细的说明一下实际中我碰到的问题我在fastreport中使用group根据条件分组([[LINE#] mod 8=0]),SQL语句为 select product_num*product_price as subtotal from input_yes where printed='0' group by product_num,product_price,product_num*product_price as subtotal 然后每条显示数量,单价和数量*单价,每张打印8条记录;最后是8条记录合计[SUM([M_DATAQUERY.ADOQuery."subtotal"])],大写合计等于该合计;否则我就需要在SQL中每8条合计一次在反映在报表中.
中间有一点好像贴错了一点 if [SUM([ADOTable1."金额"])]>99999999.99 then result:='数据溢出,错误'
直接从数据源取数
合计小写,仅仅需要把合计小写转换为大写并且显示在大写栏即可
if view.Name ='Memo25' then
view.Memo.Text:=changeMoney(aaa);其中aaa为FastReport中小写合计值
begin
end在其中写程序就行了,不要在Delphi的代码中写。
function changeMoney(TM:real):string ; //金额转换
var
shu:array of string[2];
shu1:array of string[2];
shuzi,zifu:string;temp1:integer;
begin
setlength(shu,10);setlength(shu1,10);
shu[9]:='仟';shu[8]:='佰';shu[7]:='拾';shu[6]:='万';
shu[5]:='仟';shu[4]:='伯';shu[3]:='拾';shu[2]:='圆';
shu[1]:='角';shu[0]:='分';
shu1[0]:='零';shu1[1]:='壹';shu1[2]:='贰';
shu1[3]:='叁';shu1[4]:='肆';shu1[5]:='伍';
shu1[6]:='陆';shu1[7]:='柒';shu1[8]:='捌';
shu1[9]:='玖';
shuzi:=inttostr(round(tm*100));
if tm>99999999.99 then
result:='数据溢出,错误'
else
begin
zifu:='';
temp1:=1;
while temp1<=length(shuzi) do
begin
if copy(shuzi,temp1,1)<>'0' then
begin
if copy(shuzi,temp1-1,1)='0' then zifu:=zifu+shu1[0];
zifu:=zifu+shu1[strtoint(copy(shuzi,temp1,1))]+shu[length(shuzi)-temp1];
end;
if copy(shuzi,temp1,1)='0' then
begin
if temp1=length(shuzi)-2 then zifu:=zifu+shu[2];
if temp1=length(shuzi)-6 then zifu:=zifu+shu[6];
end;
temp1:=temp1+1
end;
result:=zifu;
end;
end;
shu[9]:='仟';shu[8]:='佰';shu[7]:='拾';shu[6]:='万';
shu[5]:='仟';shu[4]:='伯';shu[3]:='拾';shu[2]:='圆';
shu[1]:='角';shu[0]:='分';
shu1[0]:='零';shu1[1]:='壹';shu1[2]:='贰';
shu1[3]:='叁';shu1[4]:='肆';shu1[5]:='伍';
shu1[6]:='陆';shu1[7]:='柒';shu1[8]:='捌';
shu1[9]:='玖';
shuzi:=[STR(ROUND([SUM([ADOTable1."金额"])]* 100))];
if [SUM([ADOTable1."金额"]>99999999.99 then
result:='数据溢出,错误'
else
begin
zifu:='';
temp1:=1;
while temp1<=length(shuzi) do
begin
if copy(shuzi,temp1,1)<>'0' then
begin
if copy(shuzi,temp1-1,1)='0' then zifu:=zifu+shu1[0];
zifu:=zifu+shu1[[INT(copy(shuzi,temp1,1))]]+shu[length(shuzi)-temp1];
end;
if copy(shuzi,temp1,1)='0' then
begin
if temp1=length(shuzi)-2 then zifu:=zifu+shu[2];
if temp1=length(shuzi)-6 then zifu:=zifu+shu[6];
end;
temp1:=temp1+1
end;
result:=zifu;
end;
memo.clear;
memo.add(result);
end
shu := '分角圆拾伯仟万拾佰仟';
shu1 := '零壹贰叁肆伍陆柒捌玖';Delphi中的函数也应该写成
var
shu, shu1: string;
begin
shu := '分角圆拾伯仟万拾佰仟';
shu1 := '零壹贰叁肆伍陆柒捌玖';
/////////////////////////////////////////////////
可是FastReport生成的报表读取memo时总得到的是"设计内容"
if view.Name ='Memo25' then
view.Memo.Text:=changeMoney(aaa);其中aaa为FastReport中小写合计值
////////////////////////////////////////////////////
在报表设计器中双击你的那个“Memo25”,在弹出的对话框的下面部分的begin和end中间加上面的代码,我这边已经做出来了才回的贴!
现在我可以详细的说明一下实际中我碰到的问题我在fastreport中使用group根据条件分组([[LINE#] mod 8=0]),SQL语句为
select product_num*product_price as subtotal from input_yes where printed='0' group by product_num,product_price,product_num*product_price as subtotal
然后每条显示数量,单价和数量*单价,每张打印8条记录;最后是8条记录合计[SUM([M_DATAQUERY.ADOQuery."subtotal"])],大写合计等于该合计;否则我就需要在SQL中每8条合计一次在反映在报表中.
if [SUM([ADOTable1."金额"])]>99999999.99 then
result:='数据溢出,错误'
交流,只能在这里,我没什么QQ之类的聊天工具,那些东东太浪费时间
[email protected]