快速报告 - 在masterdata和pagefooter band

时间:2016-10-11 10:41:17

标签: fastreport

我的masterdata乐队已将拉伸属性设置为True。 在masterdata band中,每个字段都有垂直框架线。

如果记录数量是几页或更长,我希望在每页的末尾,如果另一条记录不能放在同一页面上,以便在masterdata band和pagefooter band之间释放空间,以使线条延伸到页面脚本。

为了那个我有儿童乐队" ChildFrameLines"其目的是绘制那些框架线并填充空白区域直到页脚。

procedure MasterData1OnAfterPrint(Sender: TfrxComponent);
begin
  if Engine.Freespace < MasterData1.Height then
    Engine.Showband(ChildFrameLines);
end;

除了一种情况外,此代码可以完成工作。

让我们说页面上的最后一条记录(第10条数据记录)并不需要拉伸 并且下一页上的第一条记录(第11条数据记录)要求主数据带自身伸展以显示所有数据。

报告打印出页面上的最后一条记录后,会转到MasterData1OnAfterPrint事件并检查是否显示带子ChildFrameLines。

它表示masterdata1.height(第10条记录)比Engine.Freespace大 并且它不显示ChildFrameLines。由于第11条记录是stredhing masterdata band,因此它会转到下一页,而ChildFrameLines则不会被调用。

任何帮助表示感谢。

2 个答案:

答案 0 :(得分:0)

尝试使用双程报告。在第一次传递中将每个TfrxMasterData的高度存储在数组中的TfrxMasterData.OnAfterCalcHeight事件中,然后在第二次传递时使用存储的值

答案 1 :(得分:0)

我遇到了类似的问题,我使用与您的问题中概述的方法类似的方法解决了该问题,但使用了另一个事件。

原始解决方案的问题是您使用 OnAfterPrint 来比较主带的高度,但在这种情况下,您获得的高度是下一行的高度,不是现在的。如果所有行都具有相同的高度,您的解决方案可能看起来有效,但如果行的高度不同,则可能会失败。

我把它改成在AfterCalcHeight中做处理,其中MasterData1.Height仍然是当前行的高度。此外,我还需要填写最后一页,因此我会检查 AfterPrint 中乐队的最后一条记录(需要为此启用 DoublePass)。

这是我使用的代码:

var
  RecordCount: Integer = 0;

procedure MasterData1OnAfterCalcHeight(Sender: TfrxComponent);
begin
  // if the free space is less than the height of the current row of MasterData1 the
  // engine is going to generate a new page, so we show the child band before that
  if Engine.Freespace<MasterData1.Height then begin
    // this is one of the memos with the lines, the rest of memos have
    // StrechMode set to MaxHeight and the child band has Stretched set to True
    MemoChildFrameLines.Height:=Engine.Freespace;
    ChildFrameLines.Visible:=true;
    Engine.ShowBand(ChildFrameLines); // show the band at the current position
    ChildFrameLines.Visible:=false; // hides the band for the next record
  end;
end;

procedure MasterData1OnAfterPrint(Sender: TfrxComponent);
begin
  // DoublePass needs to be enabled so we can count the records in the first pass
  if not Engine.FinalPass then begin
    RecordCount:=RecordCount+1;
  end
  else if (<Line>=RecordCount) then begin // last record of the master data band
     MemoChildFrameLines.Height:=Engine.Freespace; // filling remaining space
     ChildFrameLines.Visible:=true;
  end;
end;

begin
  ChildFrameLines.Visible:=false; // hiding the band by default, only shown when needed
end.