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

Export Report to 10 formats in code behind

6 Answers 315 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ashraf
Top achievements
Rank 2
Ashraf asked on 28 May 2013, 03:19 PM
Hi , i used the following code to export report to excel by the code ,
i need the same code to export the report to xps format 


void ExportReport(Telerik.Reporting.Report reportToExport)
       {
           Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource();
           instanceReportSource.ReportDocument = reportToExport;
           ReportProcessor reportProcessor = new ReportProcessor();
           RenderingResult result = reportProcessor.RenderReport("XLSX", instanceReportSource, null);
 
           string fileName = result.DocumentName + "." + result.Extension;
 
           Response.Clear();
           Response.ContentType = result.MimeType;
           Response.Cache.SetCacheability(HttpCacheability.Private);
           Response.Expires = -1;
           Response.Buffer = true;
 
           Response.AddHeader("Content-Disposition",
                              string.Format("{0};FileName=\"{1}\"",
                                            "attachment",
                                            fileName));
 
           Response.BinaryWrite(result.DocumentBytes);
           Response.End();
       }
}

6 Answers, 1 is accepted

Sort by
0
Squall
Top achievements
Rank 1
answered on 29 May 2013, 02:19 PM
Just change the export format from XLSX to XPS.
0
Ashraf
Top achievements
Rank 2
answered on 29 May 2013, 02:26 PM
Thanks for reply ,
it makes thread error , STA thread error ."

The calling thread must be STA, because many UI components require this.

"
0
Accepted
IvanY
Telerik team
answered on 03 Jun 2013, 12:45 PM
Hello Ashraf,

You will have to use a separate STA thread for the XPS export, as pointed out in our online documentation, Exporting Report Programmatically.

Regards,
IvanY
Telerik

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Ashraf
Top achievements
Rank 2
answered on 03 Jun 2013, 01:13 PM
thanks for you answer !!!!!
0
shami
Top achievements
Rank 1
answered on 29 Aug 2016, 06:52 AM

hello IvanY

I am also using exactly the same code to export report in "XPS" format but it did not allow me,

the error message was, "XPS rendering format is not available" and I am not working in threads

what should I Do help plz?

0
Katia
Telerik team
answered on 29 Aug 2016, 12:46 PM
Hello Shami,

XPS rendering extension requires some additional assemblies - Telerik.Reporting.XpsRendering.dll, Telerik.Reporting.OpenXmlRendering.dll and Open XML SDK 2.0 for Microsoft Office(DocumentFormat.OpenXml.dll v.2.0.5022.0 or above with proper binding redirect).

Those assemblies can be located in Telerik Reporting installation folder: [installation folder]\Telerik\Reporting [version]\Examples\bin and [installation folder]Telerik\Reporting [version]\Bin.

After you add references to those assemblies in your project, set their CopyLocal property to True.


Regards,
Katia
Telerik by Progress
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
Ashraf
Top achievements
Rank 2
Answers by
Squall
Top achievements
Rank 1
Ashraf
Top achievements
Rank 2
IvanY
Telerik team
shami
Top achievements
Rank 1
Katia
Telerik team
Share this question
or