I needed report from runtime and disign time to be merged, so below is simpliest way to do this…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
procedure TReportSettingsEventsForm.concatReports(AresultReport: TfrxReport; a: array of TfrxReport); var i: Integer; ms: TMemoryStream; guid: TGUID; filename: string; guid2: TGUID; filename2: string; begin for i := Low(a) to High(a) do begin ms := TMemoryStream.Create(); try Createguid(guid); filename := guid.ToString() + '.fp3'; a[i].SaveToFile(filename); AresultReport.LoadFromFile(filename); AresultReport.PrepareReport(false); finally ms.free(); if TFile.Exists(filename) then TFile.Delete(filename); end; end; end; |
example of use
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
procedure TReportSettingsEventsForm.showReport; var a: array of TfrxReport; begin frxResources.LoadFromFile('Russian.frc'); // setting language PrepareDynamicReport(); MainReport.Clear(); a := [TitlePage_Runtime, Data_DesignTime, frxReport1]; concatReports(MainReport, a); with MainReport do begin PreviewOptions.ThumbnailVisible := true; ShowPreparedReport(); end; end; |
Building a composite report (batch printing)
In some cases it is required to organize printing of several reports at once, or
capsulate and present several reports in one preview window. To perform this, there are
tools in FastReport, which allow building a new report in addition to an already existing
one. The «TfrxReport.PrepareReport» method has the optional «ClearLastReport»
Boolean parameter, which is equal to «True» by default. This parameter defines whether it
is necessary to clear pages of the previously built report. The following code shows how to
build a batch from two reports:
frxReport1.LoadFromFile(‘1.fr3’);
frxReport1.PrepareReport;
frxReport1.LoadFromFile(‘2.fr3’);
frxReport1.PrepareReport(False);
frxReport1.ShowPreparedReport;
We load the first report and build it without displaying. Then we load the second
one into the same «TfrxReport» object and build it with the «ClearLastReport» parameter,
equal to «False». This allows the second report to be added to the one previously built.
After that, we display a finished report in the preview window.