How to Create a Report Book at run-time
You can programmatically create a report book at run-time by using the Telerik Reporting API.
The following steps are required to create a report book at run-time:
Create an instance of the ReportBook class
Add the necessary ReportSources to its
ReportSources
collection.
Alternatively, you can derive from the ReportBook class and initialize the book in the constructor if you want to separate the report book implementation details from the rest of your code.
In the sample below we add two reports:
First is the 'WeekdayReport', which is a CS/VB class inheriting from Telerik.Reporting.Report. It is added as a
TypeReportSource
- check Available ReportSources.Second is the 'Glossary.trdp' report created with the Standalone Designer. It is added wrapped in a
UriReportSource
. You need to specify the relative or full path to the TRDP file:
var reportBook = new ReportBook();
var weekdayReportSource = new TypeReportSource();
weekdayReportSource.TypeName = typeof(WeekdayReport).AssemblyQualifiedName;
reportBook.ReportSources.Add(weekdayReportSource);
var glossaryReportSource = new UriReportSource();
glossaryReportSource.Uri = "Reports\\Glossary.trdp";
reportBook.ReportSources.Add(glossaryReportSource);
Dim reportBook = New ReportBook()
Dim weekdayReportSource = New TypeReportSource()
weekdayReportSource.TypeName = GetType(WeekendReport).AssemblyQualifiedName
reportBook.ReportSources.Add(weekdayReportSource)
Dim glossaryReportSource = New UriReportSource()
glossaryReportSource.Uri = "Reports\Glossary.trdp"
reportBook.ReportSources.Add(glossaryReportSource)