Building a composite report (batch printing)

Top  Previous  Next

Sometimes a group of reports need to be printed at the same time or displayed in one preview window. FastReport has the means of adding a second report to the end of an already built report.  The “TfrxReport.PrepareReport” method has an optional “ClearLastReport” Boolean parameter which defaults to “True”. This parameter, when “True”, clears the output from the preceding built report. The following code shows how to build a batch of two reports:

 

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();

 

We load the first report and build it without display in the preview window. Then we load the second report into the same “TfrxReport” object and this time build it with the “ClearLastReport” parameter set to “False”. This allows the second report to be added to the first one built. Finally we display the finished reports in the preview window.