I want to programmatically export a report book, however this command fails when I try to compile with the error:
Error 6 Argument 2: cannot convert from 'Telerik.Reporting.ReportCollection' to 'Telerik.Reporting.ReportSource'
Telerik.Reporting.Processing.RenderingResult ReportOutput;
ReportOutput = reportProcessor.RenderReport("xls", RB,
null);
I've seen a ReportBook passed to the reportProcessor in other online examples, so I'm not sure why it's failing. I'm running 2012 Q2.
5 Answers, 1 is accepted
With the latest version of Telerik Reporting - 2012 Q2 - we have introduced the concept of the report sources. Thus our suggestion is to utilize an InstanceReportSource as elaborated in Exporting Report Programmatically help article and as shown in the following code snippet:
var instanceReportSource =
new
Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = reportBook;
var result = reportProcessor.RenderReport(
"XLS"
, instanceReportSource, deviceInfo);
Peter
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 >
Hello,
I created a report and I'm exporting it programmatically. Here's the code
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim app As String = CType(Session.Item("App"), String)
Dim deviceInfo As New System.Collections.Hashtable()
Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
Dim ContactReports As New Telerik.Reporting.Report
Dim instanceReportSource = New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = New ContactReports.TestReport
instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("par_app", app))
Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo)
Response.ContentType = "application/PDF"
Response.BinaryWrite(result.DocumentBytes)
Response.Flush()
Response.End()
End Sub
Everything works fine, but I would like to be able to create multiple reports of the same report, add them to a report book and export it.
I've seen a lot of posts and documentation, but I'm having a hard time trying to figure it out. Any help will be appreciated.
Thanks
Just to verify for anyone interested. In the given code snippet you can replace the report instance (used by the InstanceReportSource) with an instance of a ReportBook.
Regards,
Stef
Telerik