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

Export Report Book Programmatically

5 Answers 484 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shane Woodruff
Top achievements
Rank 1
Shane Woodruff asked on 02 Aug 2012, 02:49 PM

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

Sort by
0
Peter
Telerik team
answered on 06 Aug 2012, 01:42 PM
Hello Shane,

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);
All the best,
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 >

0
Shane Woodruff
Top achievements
Rank 1
answered on 06 Aug 2012, 04:52 PM
Thank you Peter. I was able to figure this out using your referenced link.
0
MV
Top achievements
Rank 1
answered on 19 Feb 2016, 07:50 PM

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

0
MV
Top achievements
Rank 1
answered on 19 Feb 2016, 08:40 PM
Nvm, I figured it out!
0
Stef
Telerik team
answered on 22 Feb 2016, 10:03 AM
Hi,

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
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
Tags
General Discussions
Asked by
Shane Woodruff
Top achievements
Rank 1
Answers by
Peter
Telerik team
Shane Woodruff
Top achievements
Rank 1
MV
Top achievements
Rank 1
Stef
Telerik team
Share this question
or