Programmatically use of .trdp report

6 posts, 0 answers
  1. André
    André avatar
    2 posts
    Member since:
    May 2016

    Posted 31 May Link to this post

    I have created one report in standalone report designer (Report.trdp), using object data source (my custom CLR type). It´s possible to programmatically load the report file and set the data source like a report created in Visual Studio (Report.cs)?

     

    Idea of code:

    Report reportFromFile = new Report(@"c:\temp\Report.trdp");
    reportFromFile.DataSource = _repository.Query().ToList();

     

    Regards,

    André

  2. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 01 Jun Link to this post

    Hello André,

    It is possible to modify the report definition. First, you will need to deserialize the report XML to a report object, as elaborated in the Deserialize Report Definition from XML file help article.

    Regards,
    Nasko
    Telerik
    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
  3. DevCraft banner
  4. André
    André avatar
    2 posts
    Member since:
    May 2016

    Posted 02 Jun Link to this post

    Hello Nasko,

    First thank you for reply,i realized that .trdp is a zip with two xml files inside. I used the file definition.xml in the deserialization and now i have a report object. But, the binding of the data not occurs correctly.

    My code:

    XmlReaderSettings settings = new XmlReaderSettings();
    settings.IgnoreWhitespace = true;
     
    Report report = null;
    using (XmlReader xmlReader = XmlReader.Create(@"c:\temp\TRDP_definition.xml", settings))
    {
        ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();
        report = (Report)xmlSerializer.Deserialize(xmlReader);
    }
     
    report.DataSource = _repository.Query().ToList();
     
    ReportProcessor reportProcessor = new ReportProcessor();
    InstanceReportSource instanceReportSource = new InstanceReportSource();
    instanceReportSource.ReportDocument = report;
    RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null);
     
    using (FileStream fs = new FileStream(@"c:\temp\test_from_xml_trdp.pdf", FileMode.Create))
    {
        fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
    }

    Is any wrong?

    Regards,

    André

     

     

  5. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 03 Jun Link to this post

    Hello André,

    When working with TRDP reports you can use the ReportPackager class to unpackage the report. For more information, please check the Report Unpackaging help article. The ReportPackager.Unpackage Method will return a Telerik.Reporting.Report object which you can use and modify.

    In case the report does not bind correctly to your List<T>, please elaborate further on the error message, so we can provide any suggestions.

    Regards,
    Nasko
    Telerik
    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
  6. Luka
    Luka avatar
    2 posts
    Member since:
    Oct 2016

    Posted 24 Nov Link to this post

    Hello, I have a similar question.
    If I unpackage a trdp report a get a Report object. And I can add an object to his DataSource.
    But I cannot access its other items that I created when designing it, e.g. a table or a textBox...

    e.g report.table1.DataSource        // table1 is not defined

    Is it possible to give parameters to a trdp report?

     

    Regards,

    Luka

  7. Stef
    Admin
    Stef avatar
    3044 posts

    Posted 24 Nov Link to this post

    Hello Luka,

    You can use the Find method to search for nested items. An example is illustrated here.

    On a side note, you may be interested in data-binding approaches like Use DataObject as a datasource for nested data items (Table, List, Crosstab, Graph)Steps: and How to Databind to Collection Properties. The Standalone Report Designer can load data from business objects by extending its configuration - Extending Report Designer.

    Regards,
    Stef
    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