ReportPackager
Packages and unpackages report documents in TRDP format. This is a zipped file format for representing report documents that stores the report definitions as either XML or JSON. Starting with Telerik Reporting Q2 2016, the TRDP has become the default target file format for Telerik Report Designer and Telerik Report Server.
Definition
Namespace:Telerik.Reporting
Assembly:Telerik.Reporting.dll
Syntax:
[AIAssistantExclude("")]
public class ReportPackager
Inheritance: objectReportPackager
Example:
The following example demonstrates how to package a report definition instance:
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
The following example demonstrates how to package a 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 report = New Report1() Dim reportPackager = New ReportPackager() Using targetStream = System.IO.File.Create("PackagedReport2.trdp")
reportPackager.Package(report, targetStream)
End Using
The following example demonstrates how to unpackage a .TRDP report definition:
var reportPackager = new ReportPackager();
using (var sourceStream = System.IO.File.OpenRead("Report1.trdp"))
{
var report = (Report)reportPackager.UnpackageDocument(sourceStream);
}
Dim report = New Report1() Dim reportPackager = New ReportPackager() Using targetStream = System.IO.File.Create("PackagedReport2.trdp")
reportPackager.Package(report, targetStream)
End Using
Constructors
Initializes a new instance of the ReportPackager class.
public ReportPackager()
Methods
Packages the specified report instance and writes the package to the specified Stream.
public void Package(IReportDocument report, Stream targetStream, ReportDefinitionFormat format = ReportDefinitionFormat.Xml)
The Report object to package.
targetStreamStreamThe target stream to write the packaged document.
formatReportDefinitionFormatThe format of the report definition stored in the package. The default value is Xml. Using Json requires the optional Telerik.Reporting.JsonSerialization assembly.
Use the targetStream parameter to specify an object that derives from the Stream class, which is designed to write to streams. Classes that derive from the Stream class include: BufferedStream, FileStream, MemoryStream, etc.
Packages the specified report instance and writes the package to the specified target file.
public void Package(IReportDocument report, string targetFile, ReportDefinitionFormat format = ReportDefinitionFormat.Xml)
The Report object to package.
targetFilestringThe target file to write the packaged document.
formatReportDefinitionFormatThe format of the report definition stored in the package. The default value is Xml. Using Json requires the optional Telerik.Reporting.JsonSerialization assembly.
Packages the specified XML or JSON report definition and writes the package to the specified Stream.
public void Package(string definition, Stream targetStream)
The XML or JSON report definition to package.
targetStreamStreamThe target stream to write the packaged document.
The report definition should be created with Telerik Report Designer (TRDX/TRDJ), or serialized with either the ReportXmlSerializer, or the
Telerik.Reporting.JsonSerialization.ReportJsonSerializer. Packaging a JSON report definition requires the optional Telerik.Reporting.JsonSerialization assembly.
Unpackages the TRDP document contained by the specified Stream.
public Report Unpackage(Stream packageStream)
The stream that contains the package to unpackage.
Returns:The Report object being deserialized.
Use the packageStream parameter to specify an object that derives from the Stream class, which is designed to write to streams. Classes that derive from the Stream class include: BufferedStream, FileStream, MemoryStream, etc.
Unpackages the TRDP and TRBP documents contained by the specified Stream.
public IReportDocument UnpackageDocument(Stream packageStream)
The stream that contains the package to unpackage.
Returns:The Report object being deserialized.
Use the packageStream parameter to specify an object that derives from the Stream class, which is designed to write to streams. Classes that derive from the Stream class include: BufferedStream, FileStream, MemoryStream, etc.