FastReport 套打全攻略

http://blog.csdn.net/jinzhili/article/details/500263

FastReport 套打全攻略  2005-7-13 22:10  原创
//以设计套打行为6行为例进行说明
一、定义变量
 TaoDa   0 是套打 1 不套打
 cPage   系统变量  页#
 caPage  系统变量  总页数
 
二、TfrPage.OnBeforePrint事件中写
{
 if TaoDa = '0' then
  begin
   title.visible:=false;   //不用打印的设置Visible为False;
   danweiv.frametyp := 0;  //只打印数据的不需要打印边框的设置 frametyp 为 0;
   ...   
  end;
 i := 0 ;   //定义一个变量并进行初始化。
}
二、主项数据.OnBeforePrint事件中写
{
 if TaoDa = '0' then
  begin
   i := i + 1;
   bm.memo := i;
   if (i > 5 ) then
    if ((i-1) mod 6 ) = 0 then newpage; 
  end;  
}

三、主项脚.OnBeforePrint事件中写
{
 j := i mod 6;
 if j <> 0 then 
  begin
   for k := j to 5 do 
    begin
     ShowBand(Child1);   //Child1是子的名称 显示空白行    
    end;
  end;
}
四、栏目脚.OnBeforePrint事件中写
{
 if cpage <> capage then 
  begin
   shi.memo := '';  //十
   bai.memo := '';  //百
   qian.memo := ''; //千
   wan.memeo := ''; //万    
  end
  else begin
   shi.memo := v1;
   bai.memo := v2;
   qian.memo := v3;
   wan.memo := v4;
  end;
}

这段代码是用来控制在有多页情况下,在最后一页上显示总金额。
其中:v1,v2,v3,v4 是自定义变量。

报表结构组成:
栏目头           //画报表的标头     
主项数据         //显示的数据,会与数据源进行绑定 
主项脚      //什么也不用放,只用来控制  visible := false;  
子               //画出空白行显示的组件  
栏目脚           //显示总的金额、数量   
页脚             //显示页数

调用方法:


frReportA.LoadFromFile(s);   s 是文件
frReportA.Dictionary.Variables['taoda']:='1';
进行查询

打印:
frReportA.PrepareReport;
frreportA.PrintPreparedReport('',1,true,frall);

预览:
frReportA.ShowReport;

 

posted @ 2018-01-26 15:32  zhaogaojian  阅读(1083)  评论(0编辑  收藏  举报