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
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
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é
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
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
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
hola,quisiera saber como usar el metodo ReportPackager y especificamente en donde usuaria el codigo para desempaquetado.