FR3.15打印空行补全页的问题(求达人帮忙再加一百分!) ( 积分: 100 )

  • 主题发起人 主题发起人 wordpress
  • 开始时间 开始时间
W

wordpress

Unregistered / Unconfirmed
GUEST, unregistred user!
最近做一个电力系统的调度操作票形如
顺序 单位 操作内容 发令人 备注
1 变电所 123 专职 123
2 变电所 123 专职 123
3......................................
4......................................
因为数据有时只有几行,有时有几十行,总之在最后页要打出空表格补全一页。
在GOOGLE里找了半天都无果,3.15的DEMO里也没找到像2.X版的DEMO里的"Print Empty grid"
后朋友说用如下代码:
var
PageLine: integer;
//在現在頁列印到第幾行
PageMaxRow: integer=15;
//設定每頁列數
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
PageLine := <line> mod PageMaxRow;
if (PageLine = 1) and (<line> > 1) then
Engine.newpage;
end;

//Footer1高度設為0
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
var
i: integer;
begin
i := iif(PageLine=0, PageMaxRow, PageLine);
while i < PageMaxRowdo
begin
i := i + 1;
Engine.ShowBand(Child1);
//印空白表格
end;
end;

可还是没实现,特别是:
i := iif(PageLine=0, PageMaxRow, PageLine);
while i < PageMaxRowdo
begin
i := i + 1;
Engine.ShowBand(Child1);
//印空白表格
end;

这一段搞不懂,后来用如下实现:
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
begin
while Engine.freespace >90do
Engine.showband(bandname)
end;
可空表是打出来了,也刚好补全一页,可是当数据数大于一页的最大数时,要翻页,第二页它就不打了。晕死啊。我都急翻了,达人们帮忙啊。如果分不够可以再加一百。小弟新来只有这些分!
 
最近做一个电力系统的调度操作票形如
顺序 单位 操作内容 发令人 备注
1 变电所 123 专职 123
2 变电所 123 专职 123
3......................................
4......................................
因为数据有时只有几行,有时有几十行,总之在最后页要打出空表格补全一页。
在GOOGLE里找了半天都无果,3.15的DEMO里也没找到像2.X版的DEMO里的&quot;Print Empty grid&quot;
后朋友说用如下代码:
var
PageLine: integer;
//在現在頁列印到第幾行
PageMaxRow: integer=15;
//設定每頁列數
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
PageLine := <line> mod PageMaxRow;
if (PageLine = 1) and (<line> > 1) then
Engine.newpage;
end;

//Footer1高度設為0
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
var
i: integer;
begin
i := iif(PageLine=0, PageMaxRow, PageLine);
while i < PageMaxRowdo
begin
i := i + 1;
Engine.ShowBand(Child1);
//印空白表格
end;
end;

可还是没实现,特别是:
i := iif(PageLine=0, PageMaxRow, PageLine);
while i < PageMaxRowdo
begin
i := i + 1;
Engine.ShowBand(Child1);
//印空白表格
end;

这一段搞不懂,后来用如下实现:
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
begin
while Engine.freespace >90do
Engine.showband(bandname)
end;
可空表是打出来了,也刚好补全一页,可是当数据数大于一页的最大数时,要翻页,第二页它就不打了。晕死啊。我都急翻了,达人们帮忙啊。如果分不够可以再加一百。小弟新来只有这些分!
 
如果每页的打印行数都固定的话,可以在SQL语句中补充值为null的行,
就是方法笨了点儿,比如,差三行就把用来打印的Query的SQL语句改写成:
select Fld1,Fld2,Fld3 From Table1
union all select null,null,null from Table1
union all select null,null,null from Table1
union all select null,null,null from Table1
 
问题是都不固定的,有时还得翻页。。急啊,头都大了,FR老是无故出错,一打印预览就自动关闭。晕。
 
没人帮帮我吗?求助!~~~~~~
新发现在代码页里好像调用系统变量line没效果。SOS。。。。
 
同求高人指点
 
1. 在页面上加一个 Child1, 一个 Footer1。
2. 在 Child1 上放置你需要的 Memo,打上边框。
3. 在 Footer1 的 OnBeforePrint 事件中填写代码(40 是到底边的高度,可根据需要调整):
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
begin
while Engine.FreeSpace > 40do
Engine.ShowBand(Child1);

end;
 
我刚开始就是想这样实现,可是无果啊,不是无法翻页就是行高不等,或者就是程序出错跳出。真是郁闷啊,备位达人能不能给我指点下呀。
 
适当调整 40 这个数值就可以了,我都是这么做的。
 
我用:
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
begin
while Engine.FreeSpace > bandname.Heightdo
Engine.ShowBand(bandname)
end;
在单页的情况下一切正常,可是当数据超过一页的时,会现第二页空白,第三页再重复打印第一页,一至打了五十多页,求助了。可能是我的分页语句不对的原因,看了下调用系统变量<line>好像无效果。
SOS啊,,,我真的是没折了。
 
procedure Footer1OnBeforePrint(Sender: TfrxComponent);
begin
while Engine.FreeSpace > bandname.Height+20do
Engine.ShowBand(bandname)
end;
 
用这句后,本来两页的内容打了51页,而且只有第一页的内容,第二页是空白,然后重复打印,哭啊。。。。
 
你把下面的代码复制后粘贴为文本文件,再把这个文本文件改名为 1.fr3, 然后复制到 FastReport 3.x 的 demo 的 main 文件夹中,运行 main 文件夹中的 FRDemo.exe,观察 Basic Reports 的 Simple List 示例的效果就知道了。
<?xml version=&quot;1.0&quot;
encoding=&quot;utf-8&quot;?>
<TfrxReport Name=&quot;&quot;
Version=&quot;3.15&quot;
DotMatrixReport=&quot;False&quot;
EngineOptions.DoublePass=&quot;True&quot;
EngineOptions.MaxMemSize=&quot;10000000&quot;
IniFile=&quot;/Software/Fast Reports&quot;
PreviewOptions.Buttons=&quot;2047&quot;
PreviewOptions.OutlineWidth=&quot;180&quot;
PreviewOptions.Zoom=&quot;1&quot;
PrintOptions.Printer=&quot;Default&quot;
ReportOptions.CreateDate=&quot;37871.9953986921&quot;
ReportOptions.Description.Text=&quot;Demonstrates how to create simple list report.&quot;
ReportOptions.LastChange=&quot;38702.6513472338&quot;
ReportOptions.VersionMajor=&quot;12&quot;
ReportOptions.VersionMinor=&quot;13&quot;
ScriptLanguage=&quot;PascalScript&quot;
ScriptText.Text=&quot;&amp;#13;&amp;#10;procedure Footer1OnBeforePrint(Sender: TfrxComponent);&amp;#13;&amp;#10;
begin
&amp;#13;&amp;#10;
while Engine.FreeSpace &amp;#62;
38do
&amp;#13;&amp;#10;
Engine.ShowBand(Child1);&amp;#13;&amp;#10;
end;
&amp;#13;&amp;#10;&amp;#13;&amp;#10;
begin
&amp;#13;&amp;#10;&amp;#13;&amp;#10;
end.
&quot;
PropData=&quot;044C65667403880003546F7003B00008446174617365747301010C3900000020446174615365743D225265706F7274446174612E437573746F6D65727344532220446174615365744E616D653D22437573746F6D657273220000095661726961626C65730100055374796C650100&quot;>
<TfrxReportPage Name=&quot;Page1&quot;
PaperWidth=&quot;210&quot;
PaperHeight=&quot;297&quot;
PaperSize=&quot;9&quot;
LeftMargin=&quot;5&quot;
RightMargin=&quot;5&quot;
TopMargin=&quot;5&quot;
BottomMargin=&quot;5&quot;
Columns=&quot;1&quot;
ColumnWidth=&quot;210&quot;
ColumnPositions.Text=&quot;0&quot;
PrintOnPreviousPage=&quot;True&quot;
HGuides.Text=&quot;&quot;
VGuides.Text=&quot;&quot;>
<TfrxReportTitle Name=&quot;Band1&quot;
Height=&quot;26.45671&quot;
Left=&quot;0&quot;
Top=&quot;18.89765&quot;
Width=&quot;755.906&quot;>
<TfrxMemoView Name=&quot;Memo1&quot;
Align=&quot;baWidth&quot;
Left=&quot;0&quot;
Top=&quot;3.77953&quot;
Width=&quot;755.906&quot;
Height=&quot;22.67718&quot;
Color=&quot;8421376&quot;
Font.Charset=&quot;1&quot;
Font.Color=&quot;16777215&quot;
Font.Height=&quot;-16&quot;
Font.Name=&quot;Arial&quot;
Font.Style=&quot;1&quot;
HAlign=&quot;haCenter&quot;
Memo.Text=&quot;Customers&quot;
ParentFont=&quot;False&quot;
VAlign=&quot;vaCenter&quot;/>
</TfrxReportTitle>
<TfrxPageHeader Name=&quot;Band2&quot;
Height=&quot;34.01577&quot;
Left=&quot;0&quot;
Top=&quot;68.03154&quot;
Width=&quot;755.906&quot;>
<TfrxMemoView Name=&quot;Memo4&quot;
Left=&quot;204.09462&quot;
Top=&quot;7.55906&quot;
Width=&quot;158.74026&quot;
Height=&quot;18.89765&quot;
Color=&quot;16777215&quot;
Font.Charset=&quot;1&quot;
Font.Color=&quot;128&quot;
Font.Height=&quot;-13&quot;
Font.Name=&quot;Arial&quot;
Font.Style=&quot;1&quot;
Frame.Typ=&quot;8&quot;
Memo.Text=&quot;Address&quot;
ParentFont=&quot;False&quot;/>
<TfrxMemoView Name=&quot;Memo5&quot;
Left=&quot;377.953&quot;
Top=&quot;7.55906&quot;
Width=&quot;120.94496&quot;
Height=&quot;18.89765&quot;
Color=&quot;16777215&quot;
Font.Charset=&quot;1&quot;
Font.Color=&quot;128&quot;
Font.Height=&quot;-13&quot;
Font.Name=&quot;Arial&quot;
Font.Style=&quot;1&quot;
Frame.Typ=&quot;8&quot;
Memo.Text=&quot;Contact&quot;
ParentFont=&quot;False&quot;/>
<TfrxMemoView Name=&quot;Memo6&quot;
Left=&quot;514.01608&quot;
Top=&quot;7.55906&quot;
Width=&quot;83.14966&quot;
Height=&quot;18.89765&quot;
Color=&quot;16777215&quot;
Font.Charset=&quot;1&quot;
Font.Color=&quot;128&quot;
Font.Height=&quot;-13&quot;
Font.Name=&quot;Arial&quot;
Font.Style=&quot;1&quot;
Frame.Typ=&quot;8&quot;
Memo.Text=&quot;Phone&quot;
ParentFont=&quot;False&quot;/>
<TfrxMemoView Name=&quot;Memo7&quot;
Left=&quot;612.28386&quot;
Top=&quot;7.55906&quot;
Width=&quot;102.04731&quot;
Height=&quot;18.89765&quot;
Color=&quot;16777215&quot;
Font.Charset=&quot;1&quot;
Font.Color=&quot;128&quot;
Font.Height=&quot;-13&quot;
Font.Name=&quot;Arial&quot;
Font.Style=&quot;1&quot;
Frame.Typ=&quot;8&quot;
Memo.Text=&quot;Fax&quot;
ParentFont=&quot;False&quot;/>
<TfrxMemoView Name=&quot;Memo3&quot;
Left=&quot;7.55906&quot;
Top=&quot;7.55906&quot;
Width=&quot;181.41744&quot;
Height=&quot;18.89765&quot;
Color=&quot;16777215&quot;
Font.Charset=&quot;1&quot;
Font.Color=&quot;128&quot;
Font.Height=&quot;-13&quot;
Font.Name=&quot;Arial&quot;
Font.Style=&quot;1&quot;
Frame.Typ=&quot;8&quot;
Memo.Text=&quot;Company&quot;
ParentFont=&quot;False&quot;/>
</TfrxPageHeader>
<TfrxPageFooter Name=&quot;Band3&quot;
Height=&quot;26.45671&quot;
Left=&quot;0&quot;
Top=&quot;328.81911&quot;
Width=&quot;755.906&quot;
OnBeforePrint=&quot;Band3OnBeforePrint&quot;>
<TfrxMemoView Name=&quot;Memo2&quot;
Left=&quot;3.77953&quot;
Top=&quot;7.55905999999999&quot;
Width=&quot;710.55164&quot;
Height=&quot;15.11812&quot;
Color=&quot;16777215&quot;
Font.Charset=&quot;1&quot;
Font.Color=&quot;0&quot;
Font.Height=&quot;-11&quot;
Font.Name=&quot;Arial&quot;
Font.Style=&quot;0&quot;
Frame.Typ=&quot;4&quot;
Frame.Width=&quot;2&quot;
HAlign=&quot;haRight&quot;
Memo.Text=&quot;Page [Page] of [TotalPages]&quot;
ParentFont=&quot;False&quot;/>
</TfrxPageFooter>
<TfrxMasterData Name=&quot;Band4&quot;
Height=&quot;18.89765&quot;
Left=&quot;0&quot;
Top=&quot;162.51979&quot;
Width=&quot;755.906&quot;
Columns=&quot;1&quot;
ColumnWidth=&quot;200&quot;
ColumnGap=&quot;20&quot;
DataSet=&quot;ReportData.CustomersDS&quot;
DataSetName=&quot;Customers&quot;
RowCount=&quot;0&quot;>
<TfrxMemoView Name=&quot;Memo13&quot;
Left=&quot;3.77953&quot;
Top=&quot;0&quot;
Width=&quot;714.33117&quot;
Height=&quot;18.89765&quot;
DataSet=&quot;ReportData.CustomersDS&quot;
DataSetName=&quot;Customers&quot;
Highlight.Font.Charset=&quot;1&quot;
Highlight.Font.Color=&quot;-370606080&quot;
Highlight.Font.Height=&quot;-13&quot;
Highlight.Font.Name=&quot;Arial&quot;
Highlight.Font.Style=&quot;0&quot;
Highlight.Color=&quot;15790320&quot;
Highlight.Condition=&quot;&amp;#60;Line#&amp;#62;
mod 2&quot;
Memo.Text=&quot;&quot;
WordWrap=&quot;False&quot;/>
<TfrxMemoView Name=&quot;Memo9&quot;
Left=&quot;204.09462&quot;
Top=&quot;0&quot;
Width=&quot;173.85838&quot;
Height=&quot;18.89765&quot;
DataField=&quot;Addr1&quot;
DataSet=&quot;ReportData.CustomersDS&quot;
DataSetName=&quot;Customers&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;[Customers.&amp;#34;Addr1&amp;#34;]&quot;/>
<TfrxMemoView Name=&quot;Memo10&quot;
Left=&quot;377.953&quot;
Top=&quot;0&quot;
Width=&quot;136.06308&quot;
Height=&quot;18.89765&quot;
DataField=&quot;Contact&quot;
DataSet=&quot;ReportData.CustomersDS&quot;
DataSetName=&quot;Customers&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;[Customers.&amp;#34;Contact&amp;#34;]&quot;/>
<TfrxMemoView Name=&quot;Memo11&quot;
Left=&quot;514.01608&quot;
Top=&quot;0&quot;
Width=&quot;98.26778&quot;
Height=&quot;18.89765&quot;
DataField=&quot;Phone&quot;
DataSet=&quot;ReportData.CustomersDS&quot;
DataSetName=&quot;Customers&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;[Customers.&amp;#34;Phone&amp;#34;]&quot;/>
<TfrxMemoView Name=&quot;Memo12&quot;
Left=&quot;612.28386&quot;
Top=&quot;0&quot;
Width=&quot;102.04731&quot;
Height=&quot;18.89765&quot;
DataField=&quot;FAX&quot;
DataSet=&quot;ReportData.CustomersDS&quot;
DataSetName=&quot;Customers&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;[Customers.&amp;#34;FAX&amp;#34;]&quot;/>
<TfrxMemoView Name=&quot;Memo8&quot;
TagStr=&quot;[Customers.&amp;#34;Cust No&amp;#34;]&quot;
Left=&quot;7.55906&quot;
Top=&quot;0&quot;
Width=&quot;196.53556&quot;
Height=&quot;18.89765&quot;
DataField=&quot;Company&quot;
DataSet=&quot;ReportData.CustomersDS&quot;
DataSetName=&quot;Customers&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;[Customers.&amp;#34;Company&amp;#34;]&quot;/>
</TfrxMasterData>
<TfrxChild Name=&quot;Child1&quot;
Height=&quot;18.89765&quot;
Left=&quot;0&quot;
Top=&quot;204.09462&quot;
Width=&quot;755.906&quot;>
<TfrxMemoView Name=&quot;Memo14&quot;
Left=&quot;204.09462&quot;
Top=&quot;0&quot;
Width=&quot;173.85838&quot;
Height=&quot;18.89765&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;&quot;/>
<TfrxMemoView Name=&quot;Memo15&quot;
Left=&quot;7.55906&quot;
Top=&quot;0&quot;
Width=&quot;196.53556&quot;
Height=&quot;18.89765&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;&quot;/>
<TfrxMemoView Name=&quot;Memo16&quot;
Left=&quot;377.953&quot;
Top=&quot;0&quot;
Width=&quot;136.06308&quot;
Height=&quot;18.89765&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;&quot;/>
<TfrxMemoView Name=&quot;Memo17&quot;
Left=&quot;514.01608&quot;
Top=&quot;0&quot;
Width=&quot;98.26778&quot;
Height=&quot;18.89765&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;&quot;/>
<TfrxMemoView Name=&quot;Memo18&quot;
Left=&quot;612.28386&quot;
Top=&quot;0&quot;
Width=&quot;102.04731&quot;
Height=&quot;18.89765&quot;
Frame.Typ=&quot;15&quot;
Memo.Text=&quot;&quot;/>
</TfrxChild>
<TfrxFooter Name=&quot;Footer1&quot;
Height=&quot;22.67718&quot;
Left=&quot;0&quot;
Top=&quot;245.66945&quot;
Width=&quot;755.906&quot;
OnBeforePrint=&quot;Footer1OnBeforePrint&quot;/>
</TfrxReportPage>
</TfrxReport>
 
非常感谢kaida的耐心帮助!!
不过这段代码我放到DEMO中会出错依然看不了。算了我绝望了。现在只能用单页打印。多页就出错。单页下面的功能都实现了。先应付着吧。
不如果有高人能再帮帮我的话一定感谢。不知道可不可以先放一半分?
 
接受答案了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
687
import
I
后退
顶部