Report Designer Exporting Report Programmatically

2 posts, 0 answers
  1. David
    David avatar
    7 posts
    Member since:
    Nov 2012

    Posted 11 Jan 2016 Link to this post

    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


  2. Stef
    Stef avatar
    3611 posts

    Posted 14 Jan 2016 Link to this post

    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.

    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