This is a migrated thread and some comments may be shown as answers.

Creating a New Report Book

14 Answers 1565 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 01 Aug 2018, 07:38 PM
I'm trying to find documentation on creating a Report Book.  There seems to be very little.  Can assist me in creating a Report Book from scratch?
Examples, videos, etc would all be helpful.  

14 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 06 Aug 2018, 12:57 PM
Hello Jerry,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Talha
Top achievements
Rank 1
answered on 23 Aug 2019, 09:07 PM

How can I get a Report object from a trbp file. In case of trdx, ReportXmlSerializer.Deserialize() does the job for me.

Thanks

-Talha

0
Todor
Telerik team
answered on 28 Aug 2019, 10:09 AM

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

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Talha
Top achievements
Rank 1
answered on 28 Aug 2019, 07:25 PM

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

0
Todor
Telerik team
answered on 02 Sep 2019, 08:41 AM

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

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Talha
Top achievements
Rank 1
answered on 02 Sep 2019, 02:42 PM

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

Thanks

-Talha

0
Christopher
Top achievements
Rank 1
answered on 15 Jan 2020, 10:09 AM

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

0
Christopher
Top achievements
Rank 1
answered on 16 Jan 2020, 03:06 PM

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"
    };
            
    }
   }
0
Talha
Top achievements
Rank 1
answered on 16 Jan 2020, 04:08 PM

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.

 

0
Todor
Telerik team
answered on 20 Jan 2020, 09:42 AM

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

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Søren Agerbo
Top achievements
Rank 1
answered on 07 Dec 2020, 03:00 PM

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.

0
Todor
Telerik team
answered on 09 Dec 2020, 10:25 AM

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/.

0
Michael
Top achievements
Rank 1
answered on 06 Apr 2021, 09:35 PM

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

 

0
Todor
Telerik team
answered on 12 Apr 2021, 07:35 AM

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/.

Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
Todor
Telerik team
Talha
Top achievements
Rank 1
Christopher
Top achievements
Rank 1
Søren Agerbo
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Share this question
or