FastReport批量打印
https://www.cnblogs.com/m0488/p/3774797.html 麥麥提敏
實戰例子 D:\WorkResource\測試用例\主子從報表
9.建立復合報表(批量打印)
?
在某些情況下,需要立刻組織幾個報表打印,或者在一個打印預覽窗體中封裝并呈現幾個報表。
?
要執行這些,在FastReport中有些工具能夠允許建立一個新的報表附加在一個已經存在的報表上。
?
“TfrxReport.PrepareReport”方法中有一個選項“ClearLasReport”布爾類型參數,默認情況下他等于True,這個參數定義了是否有必要在建立報表時清除
?
前一個報表。下面的方法展示了如何從兩個報表中建立一個批量報表:
?
Pascal:
?
frxReport1.LoadFromFile('1.fr3');
?
frxReport1.PrepareReport;
?
frxReport1.LoadFromFile('2.fr3');
?
frxReport1.PrepareReport(False);
?
frxReport1.ShowPreparedReport;
?
?
?
C++:
?
frxReport1->LoadFromFile("1.fr3");
?
frxReport1->PrepareReport(true);
?
frxReport1->LoadFromFile("2.fr3");
?
frxReport1->PrepareReport(false);
?
frxReport1->ShowPreparedReport();
?
我們加載并建立第一個報表,但并沒有顯示他。然后我們加載第二個報表到同一個TfrxReport對象,并使用“ClearLastReport”參數,讓他等于False。這就允許第二個報表
?
附加在先前建立的報表之后。接下來,我們在預覽窗口中顯示一個完成的報表。
?
9.1 復合報表中的頁數
?
你可以使用“Page”,“Page#”,“TotalPages”和“TotalPages#”系統變量顯示頁數或總頁數,在復合報表中,這些變量以下面的方式工作:
?
Page - 當前報表頁數
Page# - 批量報表頁數
TotalPages - 當前報表總頁數(報表必須兩遍)
Totalpages# - 批量報表總頁數
9.2 合并符合報表頁數
?
正如上面所說的,報表設計頁中的“PrintOnPrevousPage”方法讓你在打印報表的時候使用前一頁的剩余空間接合報表。在復合報表中,允許你在前一個報表的最后一頁的剩
?
余空間創建一個新的報表。要執行這個,要使能每一個連續報表的第一個設計頁“PrintOnPreviousePage”屬性[SPAN]
?
》》》》》》》》》》》》》》》》》》》實戰
procedure TForm1.Button9Click(Sender: TObject); //批量打印
var
vVou_no :string;
vStr ,vStr1 ,vStr2,vSql : string;
begin
// ADODataSet1.RecNo := StrToInt(LabeledEdit1.Text);
ADODataSet1.Locate('vou_no',LabeledEdit1.Text,[]);
vVou_no := adodataset1.FieldByName('vou_no').AsString;
with adodataset2 do
begin
close;
Parameters.ParamByName('vou_no').Value := vVou_no ;
open;
end;
cxg_mx.ClearItems;
cxg_mx.DataController.CreateAllItems();
cxg_mx.Columns[0].Width := 100;
frxReport1.PrepareReport(True);
?
ADODataSet1.Locate('vou_no',LabeledEdit2.Text,[]);
vVou_no := adodataset1.FieldByName('vou_no').AsString;
with adodataset2 do
begin
close;
Parameters.ParamByName('vou_no').Value := vVou_no ;
open;
end;
cxg_mx.ClearItems;
cxg_mx.DataController.CreateAllItems();
cxg_mx.Columns[0].Width := 100;
//ClearLasReport這個參數定義了是否有必要在建立報表時清除前一個報表
frxReport1.PrepareReport(False);
frxReport1.ShowPreparedReport; //批量打印
end;
?
//選擇單據號
{根據選擇Y,循環獲取選取的單據號,用于批量打印,不能用dataset.first,會清除選擇Y}
procedure TForm1.Button6Click(Sender: TObject);
var
Row,RowCurrent,i : Integer;
vDJH:string;
begin
RowCurrent :=cxGridDBTableView1.DataController.FocusedRecordIndex;
with DataModule2.RFDataSet1 do
begin
while not Eof do
begin
Row := cxGridDBTableView1.DataController.FocusedRecordIndex;
if cxGridDBTableView1.ViewData.DataController.Values[Row,0] = 'Y' then
vDJH :=cxGridDBTableView1.ViewData.DataController.Values[Row,6]+'|'+vDJH;
DataModule2.RFDataSet1.Next;
Next;
end;
end;
?
for i:=RowCurrent-1 downto 0 do //RecNo的最小值等于0
begin
if cxGridDBTableView1.ViewData.DataController.Values[i,0] = 'Y' then
vDJH :=cxGridDBTableView1.ViewData.DataController.Values[i,6]+'|'+vDJH;
DataModule2.RFDataSet1.Prior;
end;
ShowMessage(vDJH);
end;
總結
以上是生活随笔為你收集整理的FastReport批量打印的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 端口号被占用:The Tomcat co
- 下一篇: matlab201a教程,实验6 - 数