Add Report to Print Project?
Hi everyone. I have a report that works well, but I want to prepare several Fast Reports and add them all together to a single print project.
Am I able to do this? The data is from various sources so compiling a single report with all of it would be incredibly difficult if not impossible.
But I don't want to send 10 different print jobs to the printer either.
Any help would be greatly appreciated.
Thank you!
This discussion has been closed.
Comments
You can use the appending of prepared reports - report.Prepare (true)
Example:
report.Load(file1);
report.Prepare(true);
report.Load(file2);
report.Prepare(true);
report.Load(file3);
report.Prepare(true);
Thank you for your help!
Am I understanding properly that this has to be a file from the file system and not one in memory?
When I try to do this, it doesn't work:
//Get Directory for Reports
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string FileString = @"\PATH\Reports\Report.frx";
string directoryString = appdata + FileString;
report.Load(directoryString);
report.RegisterData(PrintDT, "Agent");
report.RegisterData(PrintCommunicationsDT, "Communications");
report.RegisterData(PrintJobsDT, "Jobs");
foreach (FastReport.Data.DataSourceBase item in report.Dictionary.DataSources)
{
item.Enabled = true;
}
BigReport.Load(report);
BigReport.Prepare(true);
Thanks!
Hello!
Calling `BigReport.Load(anotherReport)` does not carry over data that has already been loaded from another instance. To combine multiple reports from memory (from a stream or strings) with different data sources into a single print job or PDF, use the same `Report` instance and the append mode (`Prepare(true)`):
using var merged = new Report(); for (int i = 0; i < templatesAndData.Count; i++) { merged.Load(templatesAndData[i].TemplateStream); // can be from a MemoryStream—a file on disk is not required! merged.RegisterData(templatesAndData[i].Data, “Data”); merged.GetDataSource(“Data”).Enabled = true; merged.Prepare(append: i > 0); // false for the first one, true for all subsequent ones! } merged.ShowPrepared();