14 Answers, 1 is accepted
An example of creating a report book is available in the How to: Create a Report Book at run-time article. Check also our demo ReportBook that comes with the installation of Telerik Reporting and can be found in (Telerik Reporting installation folder)\Examples\CSharp or VB\ReportLibrary\ReportBook (e.g. C:\Program Files (x86)\Progress\Telerik Reporting R2 2018\Examples\CSharp\ReportLibrary\ReportBook).
It is possible to create ReportBooks also in the Standalone Designer. I have attached a short video demonstrating how to do this. The video is silent and can be opened in a browser with installed flash plug-in.
Regards,
Todor
Progress Telerik

How can I get a Report object from a trbp file. In case of trdx, ReportXmlSerializer.Deserialize() does the job for me.
Thanks
-Talha
Hi Talha,
To create a Telerik.Reporting.Report instance from a TRBP or TRDP file you may use the Unpackage method of the ReportPackager class. You may find sample code snippets in the latter article.
Regards,
Todor
Progress Telerik

Hi Todor,
ReportPackager.UnPackageDocument() gives me a ReportBook instance. Now, I need to understand how can I assign DataSource to all the reports inside the ReportBook.
The ReportBook instance I get contains a collection of UriReportSource objects. I had thought about deserializing individual reports using the Url, add them to Reports collection and then pass that ReportBook to ReportProcessor, but I get a warning that Reports collection is obsolete.
Please let me know how I can assign DataSource to a ReportBook or each individual report.
Thanks
-Talha
Hi Talha,
The approach you have undertaken is the correct one. After deserializing the reports you just need to pass the modified reports wrapped in InstanceReportSources to the ReportBook.ReportSources collection - How to use ReportSource objects with ReportBook.
Regards,
Todor
Progress Telerik

Deserializing individual reports and adding them to ReportBook.ReportSources worked for me.
Thanks
-Talha

Hi,
I am trying to do achieve the same have you got any sample code you could share so that I can get an idea of how to implement it.
Thanks Chris

Hi Todor
I am trying to attempt the the same result as Talha, I have unpacked the ReportBook and then loop through each report and unpack them and add the data, then add to the ReportBook and render as a pdf. but It is not working the way I expecting please see my code
using
(var reportStream = System.IO.File.OpenRead(Path.Combine(
"Reports"
,
"Intervention"
,
"v1"
,
"InterventionReportBook.trbp"
)))
{
var rptBook = (ReportBook)reportPackager.UnpackageDocument(reportStream);
foreach
(var report
in
rptBook.ReportSources)
{
using
(var subReportStream = System.IO.File.OpenRead(Path.Combine(
"Reports"
,
"Intervention"
,
"v1"
,
((UriReportSource)report).Uri)))
{
var subReport = (Report)reportPackager.Unpackage(subReportStream);
var rs =
new
InstanceReportSource
{
ReportDocument = subReport
};
subReport.Items.Find<List>(
"listLearnerDetails"
, dataSource,
"GetLearnerData"
);
subReport.Items.Find<List>(
"listStrategies"
, dataSource,
"GetStrategies"
);
subReport.Items.Find<List>(
"listExtraNotes"
, dataSource,
"GetData"
);
report.RerportSource = rs;
}
}
reportSource.ReportDocument = rptBook;
}
var result = reportProcessor.RenderReport(
"PDF"
, reportSource, deviceInfo);
return
new
FileContentResult(result.DocumentBytes,
"application/pdf"
)
{
FileDownloadName =
"InterventionReport.pdf"
};
}
}

What I have done is pretty much same, except I am not trying to replace the ResportSource while reading it inside the loop.
I am creating a new list of InstanceReportSource objects, clearing the existing ReportSources collections of the ReportBook, and then adding the list of InstanceReportSource objects to the ReportBook's ReportSources collection.
Hi Christopher,
From the code, I infer that the variable 'report' is a ReportSource. This would mean that 'report.RerportSource = rs;' is not valid. You may store the new InstanceReportSources for the ReportBook in a collection, and after modifying them to replace the ReportSources collection of the ReportBook with the new collection as suggested by Talha.
I noticed that you use code like:
subReport.Items.Find<List>("listLearnerDetails", dataSource, "GetLearnerData");
Our Report class does not expose method Find with the above signature and I suspect this is a custom extension.
Can you specify what is not working as expected?
You may troubleshoot whether the data sources are applied correctly by exporting each report with a modified data source in TRDX file, and then open this file in a text editor to check whether the data source is serialized in the report definition.
Regards,
Todor
Progress Telerik

Hi,
I am working with this code:
[Description("A collection of Reports")]
public class Report_book : Telerik.Reporting.ReportBook
{
public Report_book()
{
AddTocTemplate();
//AddReports();
}
void AddTocTemplate()
{
var tocReportSource = new TypeReportSource();
tocReportSource.TypeName = typeof(TOC).AssemblyQualifiedName;
this.TocReportSource = tocReportSource;
}
But when i try to run it on IIS, it comes up with the error, not set to an instance of an object.
Hi Søren,
The error message is too general to infer what may be going wrong.
Can you attach a Trace Listener to the project and send us the generated log for investigation?
You may also check the event viewer for relevant errors.
Regards,
Todor
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Hi,
I have 4 reports created in Report Designer and saved in report server. Now i want to use core to create reportbook that include those 4 reports from report server and display as pdf. I have looked for all resources but I can't find any examples of how to create reportbook in core. Please help.
thanks
Hi Michael,
The programmatical creation of the Report Book in .NET Core happens with the same code as in the .NET Framework - see How to Create a Report Book at run-time. We provide a demo in our samples that get deployed with the installation of the product. In the folder .NET Core 3.1, there is a CSharp.ReportLibrary project with a ReportBook that is created with code.
If you use TRDP reports from the Report Server, you need to download them locally with the Report Server API and pass them to the ReportBook in UriReportSources. You may also unpackage the reports with the ReportPackager class and pass them to the ReportBook in InstanceReportSources.
The ReportBook can be exported with the ReportProcessor programmatically in any of the supported formats.
Regards,
Todor
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.