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

Create reportbook dynamically

2 Answers 251 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Manfred
Top achievements
Rank 2
Manfred asked on 27 Jul 2012, 01:24 PM
Hi there,

we have a ServiceOrderReport which works fine at the moment.
But our customers want to load a bunch of Reports at one time to export them to pdf.
Is it possible to generate a reportbook with  two or more Reports dynamically at runtime?

If it is possible, does someone have a short example?

Best Regards
Manfred

2 Answers, 1 is accepted

Sort by
0
Francis
Top achievements
Rank 1
answered on 30 Jul 2012, 05:25 PM
Hi,

I have a reportbook generated programatically in the Page_load of my report.aspx, it contains 3 default reports that must show once the report book is loaded. This is working fine. However there are four optional reports that the user can choose to display by selecting options on the parameter UI of the web report viewer. My question is how do I get to add the optional reports to the report book once the user selects them and clicks on the Preview button - The Page_load is not called again and I have no way on intercepting the Preview click event from code behind? I am currently using Q1 2012 Telerik report and was wondering if anything has been added in the form of say a ReportBook before rendering event in Q2 2012 based on http://www.telerik.com/community/forums/reporting/telerik-reporting/silverlight-reportviewer-and-reportbook.aspx#1435670 . Any and all the help is greatly appreciated.


Regards

Francis. 
0
Charlie
Top achievements
Rank 2
answered on 31 Jul 2012, 02:01 PM
We have a method that creates a ReportBook and several Report instances (SummaryRollup below) and adds them to the book.  Then the ReportBook is sent to a Print method.
I'll include some code, I hope it helps.  If not, let me know.

    ReportBook reportBook = new ReportBook();
    reportBook.DocumentName = documentName;
 
    // Create the Summary Rollup model and report.
    SummaryRollup rollupPage = new SummaryRollup();
    SummaryRollupModel rollupModel = new SummaryRollupModel("PageTitle");
    rollupPage.ReportModel = rollupModel;
    reportBook.Reports.Add(rollupPage);
    this.RenderPdfReport(report, PdfPathString);
 
 
public void RenderPdfReport(IReportDocument report, string documentPath)
{
    InstanceReportSource reportSource = new InstanceReportSource();
    reportSource.ReportDocument = report;
    ReportProcessor reportProcessor = new ReportProcessor();
    Hashtable deviceInfo = new Hashtable();
    deviceInfo["FontEmbedding"] = "None";
    RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);
    if (result.DocumentBytes == null)
    {
        return;
    }
    using (FileStream fs = new FileStream(documentPath, FileMode.Create))
    {
        fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
    }
}

Tags
General Discussions
Asked by
Manfred
Top achievements
Rank 2
Answers by
Francis
Top achievements
Rank 1
Charlie
Top achievements
Rank 2
Share this question
or