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

Programmatically use of .trdp report

6 Answers 2329 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
André
Top achievements
Rank 1
André asked on 31 May 2016, 08:26 PM

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é

6 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 01 Jun 2016, 02:07 PM
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
0
André
Top achievements
Rank 1
answered on 02 Jun 2016, 12:36 PM

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é

 

 

0
Nasko
Telerik team
answered on 03 Jun 2016, 12:03 PM
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
0
Luka
Top achievements
Rank 1
answered on 24 Nov 2016, 10:14 AM

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

0
Stef
Telerik team
answered on 24 Nov 2016, 02:28 PM
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
0
ivan
Top achievements
Rank 1
answered on 21 Jun 2018, 04:53 PM

hola,quisiera saber como usar el metodo ReportPackager y especificamente en donde usuaria el codigo para desempaquetado.

 

Tags
Report Designer (standalone)
Asked by
André
Top achievements
Rank 1
Answers by
Nasko
Telerik team
André
Top achievements
Rank 1
Luka
Top achievements
Rank 1
Stef
Telerik team
ivan
Top achievements
Rank 1
Share this question
or