Serializing and Deserializing Report Definitions
Telerik Reporting supports serialization/deserialization of the report definition as plain XML or JSON. The TRDX, TRDJ, and TRDP files are declarative report definitions:
TRDXis a self-contained XML report definition. All embedded images are serialized in the XML file.TRDJis a self-contained JSON report definition. All embedded images are serialized in the JSON file.TRDPis a ZIP archive containing the report definition as XML by default, but it can hold it as JSON too. It may also contain resources like image and localization files packed in the archive.
The report serialization/deserialization is useful in various scenarios and opens many possibilities that are not easily accomplished otherwise. For example, this allows adding or modifying reports in your application without recompiling or redeploying it. Another typical scenario is saving/loading dynamically generated report definitions or transferring them over the network.
To better handle report definition resources, we also provide a ReportPackager that serializes the report definition in XML or JSON and packages it together with its resources in a file with zip compression. For more information, see Package Report Definition.
Class Report Definition
The XML serialization/deserialization of report definitions is achieved through the dedicated ReportXmlSerializer class.
The JSON serialization/deserialization of report definitions is achieved through the dedicated ReportJsonSerializer class.
To illustrate how a report is serialized and deserialized, let us start with a simple dynamically generated class report definition:
var report = new Report1();
report.Width = Telerik.Reporting.Drawing.Unit.Inch(4);
var detailSection = new Telerik.Reporting.DetailSection();
detailSection.Height = Telerik.Reporting.Drawing.Unit.Inch(0.2);
report.Items.Add(detailSection);
var numberTextBox = new Telerik.Reporting.TextBox();
numberTextBox.Value = "=Fields.ProductNumber";
numberTextBox.Left = Telerik.Reporting.Drawing.Unit.Inch(0);
numberTextBox.Top = Telerik.Reporting.Drawing.Unit.Inch(0);
numberTextBox.Width = Telerik.Reporting.Drawing.Unit.Inch(2);
numberTextBox.Height = Telerik.Reporting.Drawing.Unit.Inch(0.2);
detailSection.Items.Add(numberTextBox);
var nameTextBox = new Telerik.Reporting.TextBox();
nameTextBox.Value = "=Fields.Name";
nameTextBox.Left = Telerik.Reporting.Drawing.Unit.Inch(2);
nameTextBox.Top = Telerik.Reporting.Drawing.Unit.Inch(0);
nameTextBox.Width = Telerik.Reporting.Drawing.Unit.Inch(2);
nameTextBox.Height = Telerik.Reporting.Drawing.Unit.Inch(0.2);
detailSection.Items.Add(nameTextBox);
var dataSource = new Telerik.Reporting.SqlDataSource();
dataSource.ConnectionString = "Data Source=.\\SqlExpress;Initial Catalog=AdventureWorks;Integrated Security=True";
dataSource.SelectCommand = "select ProductNumber, Name from Production.Product";
report.DataSource = dataSource;Report1 is a derivative of the basic Report class. A similar implementation can be found in the installation folder of the Telerik Reporting product, usually located at the following path: Progress\Telerik Reporting 2026 Q3\Examples\CSharp.NET Framework\ReportLibrary. You can refer to the ProductCatalog implementation. However, the code is valid for the basic Report implementation as well. It will contain a more simplified design with just the text boxes added to the report.
Serialize to XML
The following sample code snippet demonstrates how to serialize the above report definition to an XML file:
using (System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create("SerializedReport.xml"))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
xmlSerializer.Serialize(xmlWriter, report);
}Deserialize from XML
The corresponding code that can be used to deserialize the report definition from the file is shown below:
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
settings.IgnoreWhitespace = true;
using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create("Report1.xml", settings))
{
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize(xmlReader);
}and the resulting XML file would look like this:
XML Report Definition
<Report DataSourceName="sqlDataSource1" Width="4in" Name="userReport1" xmlns="http://schemas.telerik.com/reporting/2012/2">
<DataSources>
<SqlDataSource ConnectionString="Data Source=.\SqlExpress;Initial Catalog=AdventureWorks;Integrated Security=True" SelectCommand="select ProductNumber, Name from Production.Product" Name="sqlDataSource1" />
</DataSources>
<Items>
<DetailSection Height="0.2in" Name="detailSection1">
<Items>
<TextBox Value="=Fields.ProductNumber" Size="2in, 0.2in" Location="0in, 0cm" Name="textBox1" />
<TextBox Value="=Fields.Name" Size="2in, 0.2in" Location="2in, 0cm" Name="textBox2" />
</Items>
</DetailSection>
</Items>
<PageSettings>
<PageSettings PaperKind="Letter" Landscape="False">
<Margins>
<MarginsU Left="1in" Right="1in" Top="1in" Bottom="1in" />
</Margins>
</PageSettings>
</PageSettings>
</Report>
Serialize to JSON
Serializing and deserializing JSON report definitions requires the 'Telerik.Reporting.JsonSerialization' assembly, which is not part of the 'Telerik.Reporting' assembly. To do this, install the 'Telerik.Reporting.JsonSerialization' NuGet package (or add a reference to 'Telerik.Reporting.JsonSerialization.dll') and make sure it is deployed next to 'Telerik.Reporting.dll'.
The following sample code snippet demonstrates how to serialize the above report definition to a JSON file:
using (System.IO.Stream stream = new System.IO.FileStream("Report.json", System.IO.FileMode.Create))
{
Telerik.Reporting.JsonSerialization.ReportJsonSerializer jsonSerializer =
new Telerik.Reporting.JsonSerialization.ReportJsonSerializer();
jsonSerializer.Serialize(stream, report);
}Deserialize from JSON
The corresponding code that can be used to deserialize the report definition from the file is shown below:
using (System.IO.FileStream fileStream = new System.IO.FileStream("Report1.json", System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
Telerik.Reporting.JsonSerialization.ReportJsonSerializer jsonSerializer =
new Telerik.Reporting.JsonSerialization.ReportJsonSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
jsonSerializer.Deserialize(fileStream);
}JSON Report Definition
The resulting JSON file would look like this, if unminified:
{
"$schema": "http://schemas.telerik.com/reporting/2026/3.0",
"NetType": "Report",
"DataSource": "sqlDataSource1",
"Width": "4in",
"Name": "userReport1",
"DataSources": [
{
"NetType": "SqlDataSource",
"QueryDesignerState": "null",
"ParameterValues": "null",
"ConnectionString": "RGF0YSBTb3VyY2U9LlxTcWxFeHByZXNzO0luaXRpYWwgQ2F0YWxvZz1BZHZlbnR1cmVXb3JrcztJbnRlZ3JhdGVkIFNlY3VyaXR5PVRydWU=",
"SelectCommand": "select ProductNumber, Name from Production.Product",
"Name": "sqlDataSource1"
}
],
"Items": [
{
"NetType": "DetailSection",
"Height": "0.2in",
"Name": "detailSection1",
"Items": [
{
"NetType": "TextBox",
"Width": "2in",
"Height": "0.2in",
"Left": "0in",
"Top": "0cm",
"Value": "=Fields.ProductNumber",
"Name": "textBox1"
},
{
"NetType": "TextBox",
"Width": "2in",
"Height": "0.2in",
"Left": "2in",
"Top": "0cm",
"Value": "=Fields.Name",
"Name": "textBox2"
}
]
}
],
"PageSettings": {
"PaperKind": "Letter",
"Landscape": false,
"ColumnCount": 1,
"ColumnSpacing": "0in",
"Margins": {
"NetType": "MarginsU",
"Left": "1in",
"Right": "1in",
"Top": "1in",
"Bottom": "1in"
}
}
}