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

Can no longer export reportbook to PDF - Invalid ReportSource

1 Answer 170 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Clyde
Top achievements
Rank 1
Clyde asked on 12 Jun 2012, 07:30 PM
I've just upgraded to the 611 version and I can no longer successfully build my solution. It seems that the RenderReport method will no longer accept a ReportBook parameter although all the documentation claims that it does.

My scenario is that I create a ReportBook from 3 Reports and then pass it over to the ExportToPDF method. I now get the following compile time errors.

Error    66    Argument 2: cannot convert from 'Telerik.Reporting.ReportBook' to 'Telerik.Reporting.ReportSource'   
Error    65    The best overloaded method match for 'Telerik.Reporting.Processing.ReportProcessor.RenderReport(string, Telerik.Reporting.ReportSource, System.Collections.Hashtable)' has some invalid arguments


    void ExportToPDF(string reportName, Telerik.Reporting.IReportDocument reportToExport)
    {
        ReportProcessor reportProcessor = new ReportProcessor();
        RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);
 
       using (FileStream fs = new FileStream(fileName, FileMode.Create))
        {
            fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
        }
     }

I have tried multiple ways to configure this using the ReportSource class but am unable to figure out how this works.

Your assistance, as always, is greatly appreciated.

Thanks
Clyde

1 Answer, 1 is accepted

Sort by
0
Accepted
IvanY
Telerik team
answered on 13 Jun 2012, 03:51 PM
Hi Clyde,

Because of the new ReportSource you need to handle the ReportBook export differently. Create instance of InstanceReportSource and pass to its property ReportDocument your ReportBook. After that use the new InstanceReportSource in the place of the ReportBook.

Here is a sample:
InstanceReportSource reportSource = new InstanceReportSource();
reportSource.ReportDocument = new MyReportBook();
 
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, null);

We would improve the ReportBook handling for subsequent versions.

Regards,
IvanY
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Clyde
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Share this question
or