Progress® Telerik® Reporting R1 2018

How to: Set ReportSource for ReportProcessor

The ReportProcessor class can be used for exporting and printing Telerik Reports programmatically. The article elaborates how to specify which report to be processed. You will need a Report Source object.

When you use the Report Processor to directly print (PrintReport) or render (RenderReport) a report, the argument is of ReportSource type. The report source you will use depends on the format of the report.

For this example we will use a TypeReportSource (see Report Sources link below) suitable for work with reports created in Visual Studio Report Designer - classes inheriting Telerik.Reporting.Report|ReportBook. The TypeReportSource specifies the report by its Assembly Qualified Name, where the Reporting Engine uses Reflection to create an instance of the report class through its default parameterless constructor.

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);

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article