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

Report Designer Exporting Report Programmatically

1 Answer 827 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 11 Jan 2016, 05:44 PM

I'm using: Report Designer Q3 2014 and I can not get run a report that I need to export a report directly to PDF, without the need to go through the web viewer. I'm in a WEB .NET (C#) application and all the examples does not run for one reason or other!!.

I need to pass three parameters to the report and I can not find a usefull example. I already see the article: "Exporting a report to PDF programmatically" but still not function.

For example I've used this code:

Telerik.Reporting.Processing.ReportProcessor reportProcessor =
    new Telerik.Reporting.Processing.ReportProcessor();
// set any deviceInfo settings if necessary
System.Collections.Hashtable deviceInfo =
    new System.Collections.Hashtable();
Telerik.Reporting.TypeReportSource typeReportSource =
             new Telerik.Reporting.TypeReportSource();
// reportName is the Assembly Qualified Name of the report
typeReportSource.TypeName = reportName;
Telerik.Reporting.Processing.RenderingResult result =
    reportProcessor.RenderReport("PDF", typeReportSource, deviceInfo);
string fileName = result.DocumentName + "." + result.Extension;
string path = System.IO.Path.GetTempPath();
string filePath = System.IO.Path.Combine(path, fileName);
using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
    fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}

 

And in this case shows the next error:

Line 88: Telerik.Reporting.Processing.RenderingResult result = Line 89:                 reportProcessor.RenderReport("PDF", typeReportSource, deviceInfo);

Looks like is NULL de "deviceInfo"....

 

Please help!...any help would be appreciated

David

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 14 Jan 2016, 10:12 AM
Hello David,

Please check the Exporting Report Programmatically help article.
The TypeReportSource can be replaced by a report source suitable for the type of reports you have. To pass parameters to the report, update the report source's Parameters collection, which is mapped to the report's ReportParameters collection by key (name). For more details check Report Sources.

I hope this helps.

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
David
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or