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

Slightly confused about exporting reports.

1 Answer 118 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 23 Oct 2014, 02:31 PM
I'm currently trialling Reporting, and am a little confused as to how to export a report with data from C#.

I am using the standalone report designer to save a trdx file using the ObjectDataSource and I'm trying to export to PDF, looking at the KB I have the following code block:

Order tempOrder = new Order("12345", "Mr Test");
 
            Telerik.Reporting.Report report = new Telerik.Reporting.Report();
            report.DataSource = tempOrder;
 
            System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
            UriReportSource reportSource = new UriReportSource();
            reportSource.Uri = @"E:\Program Files (x86)\Telerik\Reporting Q2 2014\Report Designer\Examples\Order.trdx";
            Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
            Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, 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);
            }

Which seems to output a pdf using my trxd file however I can find no way to pass in both the data source (or the Report variable with data source defined) and the path to the trdx file. 

1 Answer, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 28 Oct 2014, 10:42 AM
Hi Mark,

If your intend is to use the same data as at designing the report, please check the Deploying trdx (XML report definition) that uses external assembly KB article.

In case you want to change the data, you will have to deserialize the report into Telerik.Reporting.Report object and set the report's and nested data items' DataSource properties at run-time. An example of such approach is illustrated in the Changing the connection string dynamically according to runtime data KB article.


I hope the above information is helpful.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Report Designer (standalone)
Asked by
Mark
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or