Export Report to 10 formats in code behind

7 posts, 1 answers
  1. Ashraf
    Ashraf avatar
    40 posts
    Member since:
    Aug 2012

    Posted 28 May 2013 Link to this post

    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();
           }
    }
  2. Squall
    Squall avatar
    174 posts
    Member since:
    Feb 2011

    Posted 29 May 2013 Link to this post

    Just change the export format from XLSX to XPS.
  3. DevCraft banner
  4. Ashraf
    Ashraf avatar
    40 posts
    Member since:
    Aug 2012

    Posted 29 May 2013 Link to this post

    Thanks for reply ,
    it makes thread error , STA thread error ."

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

    "
  5. Answer
    IvanY
    Admin
    IvanY avatar
    417 posts

    Posted 03 Jun 2013 Link to this post

    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.

  6. Ashraf
    Ashraf avatar
    40 posts
    Member since:
    Aug 2012

    Posted 03 Jun 2013 Link to this post

    thanks for you answer !!!!!
  7. shami
    shami avatar
    4 posts
    Member since:
    Aug 2016

    Posted 29 Aug in reply to IvanY Link to this post

    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?

  8. Katia
    Admin
    Katia avatar
    308 posts

    Posted 29 Aug Link to this post

    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
Back to Top
DevCraft banner