在FastReport VCL 5中添加带宽以上的空间

时间:2015-01-15 15:39:40

标签: delphi fastreport

我有一张我正在处理的发票表单,我使用页眉带作为主数据(以便每页显示发票标题信息),然后使用主带显示发票的行项目和最后另一个主要乐队显示总数(总计以多种货币打印)。我想从第一个空间开始第二个主乐队,但我看不到这样做的方法。

PAGE HEADER (with invoice header)
MASTER DATA BAND (with invoice detail)
<need space here>
MASTER DATA BAND (with invoice totals)
FOOTER
PAGE FOOTER

更新: 以下是我的报告中如何布置条带: Report Bands Layout

如果我把建议的代码放在MasterData:Totals OnBeforePrint中,那么这就是我得到的(我用40而不是5来明显区别对待):

Sample with Spacing

以下是没有代码的情况:

Sample without Spacing

这是我的代码:

procedure TotalsOnBeforePrint(Sender: TfrxComponent);
begin
  if Engine.FreeSpace > Totals.Height + Footer.Height + PageFooter.Height + 40 then
    Engine.CurY := Engine.CurY + 40;  
end;

(我在if语句中翻了标志,否则几乎不会执行。)

3 个答案:

答案 0 :(得分:1)

将空子带添加到masterdata band 在Child的OnBeforePrint活动中使用:

Child1.Visible:= not Totals.Dataset.Eof;

答案 1 :(得分:0)

如果细节总带宽是固定高度,则可以使用乐队OnBeforePrint(脚本)。我已经使用了值5 - 将它设置为你想要的任何间距,然后再进行乐队打印:

procedure MasterDataTotalBandBeforePrint(Sender: TfrxComponent);
begin
  // See if there's room for the band between the bottom of the last
  // band (MasterDataDetail) and the footer and page footer.

  if Engine.FreeSpace > MasterDataTotalBand.Height + FooterBand1.Height +
                        PageFooter1.Height + 5 then
    Engine.CurY := Engine.CurY + 5;
end;

答案 2 :(得分:0)

基于@ gpi的评论,我在MasterData:MasterData乐队(技术上是TariffRemarks乐队的孩子)中添加了一个Child band(名为Spacer)。然后我将以下脚本添加到Child Band的OnBeforePrint事件中:

procedure SpacerOnBeforePrint(Sender: TfrxComponent);
begin
  Spacer.Visible := MasterData.Dataset.RecNo = MasterData.Dataset.RecordCount - 1;
end;

这很有效。我不确定为什么MasterData.Dataset.eof不起作用,但我认为最后一条记录的OnBeforePrint事件在表超过最后一条记录之前触发并将eof标志设置为true。我想Recno是基于0的,所以MasterData.Dataset.Recno = MasterData.Dataset.Recordcount也不起作用。