如何把FastReport中生成的数据提取到程序变量中?

解决方案 »

  1.   

    Fastreport中的数据不都是从dataset中取得的吗?
    直接从数据源取数
      

  2.   

    使用SUM函数得到的结果需要更改为金额大写,所以需要提取变量.
      

  3.   

    直接在FastReport中就可以写程序
      

  4.   

    这样的情况最好在程序中取到总数,转换完后在表现在fastreport中
      

  5.   

    我的大写函数没有错误,因为我使用了分组,所以要对每张进行金额合计,在FastReport中已经得到了
    合计小写,仅仅需要把合计小写转换为大写并且显示在大写栏即可
      

  6.   

    可是FastReport生成的报表读取memo时总得到的是"设计内容"
    if view.Name ='Memo25' then
       view.Memo.Text:=changeMoney(aaa);其中aaa为FastReport中小写合计值
      

  7.   

    设计报表的时候有上下两个输入框,上面的直接输入“设计内容”,下面还有一个是用来写程序的,里面写了一个
       begin
       
       end在其中写程序就行了,不要在Delphi的代码中写。
      

  8.   

    把你的金额小写到大写的函数贴出来,我帮你改成FastReport设计器中的代码!
      

  9.   

    我已经自定义了一个函数
    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;
      

  10.   

    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
      

  11.   

    前面的两段可以也应该改为
    shu := '分角圆拾伯仟万拾佰仟';
    shu1 := '零壹贰叁肆伍陆柒捌玖';Delphi中的函数也应该写成
    var
      shu, shu1: string;
    begin
      shu := '分角圆拾伯仟万拾佰仟';
      shu1 := '零壹贰叁肆伍陆柒捌玖';
      

  12.   

    ADOTable1."金额"  ,改为你的那个金额字段
    /////////////////////////////////////////////////
    可是FastReport生成的报表读取memo时总得到的是"设计内容"
    if view.Name ='Memo25' then
       view.Memo.Text:=changeMoney(aaa);其中aaa为FastReport中小写合计值
    ////////////////////////////////////////////////////
    在报表设计器中双击你的那个“Memo25”,在弹出的对话框的下面部分的begin和end中间加上面的代码,我这边已经做出来了才回的贴!
      

  13.   

    写法均可,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条合计一次在反映在报表中.
      

  14.   

    中间有一点好像贴错了一点 
     if [SUM([ADOTable1."金额"])]>99999999.99 then
        result:='数据溢出,错误'
      

  15.   

    你好,我是cjzy22,和你交流后,受益匪浅;我如果使用自定义函数如何实现
      

  16.   

    暂时还不知道,刚接触FastReport,不太清楚其他的。
      

  17.   

    到http://www.google.com/上面搜索“FastReport 开发指南”,下载一个看看。
    交流,只能在这里,我没什么QQ之类的聊天工具,那些东东太浪费时间
      

  18.   

    回头有问题用邮箱交流
    [email protected]