Packaging and Unpackaging Report Definitions
The ReportPackager serializes the report definition in XML and with a zip compression packages the definition and its resources. The resources are in their native format and archived for better performance. This way the definition is faster to handle and more compact. This is the default report document format for the Standalone Report Designer and the Web Report Designer.
Packaging .TRDX report definition
The following sample code snippet demonstrates how to package a predefined .TRDX (XML) report definition:
var reportPackager = new ReportPackager();
using (var targetStream = System.IO.File.Create("PackagedReport2.trdp"))
{
var xmlString = System.IO.File.ReadAllText("Report1.trdx");
reportPackager.Package(xmlString, targetStream);
}
Dim reportPackager = New ReportPackager()
Using targetStream = System.IO.File.Create("PackagedReport3.trdp")
Dim xmlString = System.IO.File.ReadAllText("Report1.trdx")
reportPackager.Package(xmlString, targetStream)
End Using
Packaging CLR report definition
The following sample code snippet demonstrates how to package a predefined CLR (C# or VB) report definition:
var report = new Report1();
var reportPackager = new ReportPackager();
using (var targetStream = System.IO.File.Create("PackageReport1.trdp"))
{
reportPackager.Package(report, targetStream);
}
Dim report = New Report1()
Dim reportPackager = New ReportPackager()
Using targetStream = System.IO.File.Create("PackagedReport2.trdp")
reportPackager.Package(report, targetStream)
End Using
Unpackaging
The following sample code snippet demonstrates how to unpackage a predefined .TRDP report definition:
var reportPackager = new ReportPackager();
using (var sourceStream = System.IO.File.OpenRead("Report1.trdp"))
{
var report = (Report)reportPackager.UnpackageDocument(sourceStream);
}
Dim reportPackager = New ReportPackager()
Using sourcetStream = System.IO.File.OpenRead("Report1.trdp")
Dim report = reportPackager.Unpackage(sourcetStream)
End Using