FastReport分组打印并且指定每页行数(不足填空行)

本文介绍使用FastReport进行复杂报表设计的方法,重点讲解如何实现分组内的页脚处理及页面计数功能。通过定义变量和在不同事件中设置逻辑来控制报表输出,包括如何在每个分组结束时记录总页数,并在最终输出页显示总页号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

var
  GPage,GIndex,FGIndex:integer;
  PageList:array of integer;
  PageLine: integer;      
  PageMaxRow: integer=28;         
 
procedure PageFooter1OnBeforePrint(Sender: TfrxComponent);
begin
  GPage := GPage + 1;
end;

procedure Page1OnBeforePrint(Sender: TfrxComponent);
begin
  GPage :=1;                                       
end;

procedure GroupFooter1OnBeforePrint(Sender: TfrxComponent);
var
  i: integer;   
begin
  if Engine.FinalPass then  //二次遍历时增加分组索引
    FGIndex := FGIndex + 1
  else
  begin
    setLength(PageList,GIndex + 1);                                                                   
    PageList[GIndex] := GPage; //存放分组的总页数         
    GIndex := GIndex + 1;
  end;
  GPage := 0;

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

procedure Memo6OnBeforePrint(Sender: TfrxComponent);
begin
  if not Engine.FinalPass then exit;
  //Memo6.Lines[0] := '总页号:'+IntToStr(PageList[FGIndex]);
  Memo6.Lines[0] := '总页号:'+IntToStr(FGIndex+1);     
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;      
end;}


begin
  FGIndex :=0;       
end.

FastReport界面为:

2010082717061543.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值