Progress® Telerik® Reporting R3 2020
ReportXmlSerializer Class
Serializes and deserializes objects into and from XML.
This class is dedicated for serializing and deserializing objects
only from the Telerik.Reporting namespace.
Inheritance Hierarchy
SystemObject
Telerik.Reporting.XmlSerializationReportXmlSerializer
Namespace:
Telerik.Reporting.XmlSerializationTelerik.Reporting.XmlSerializationReportXmlSerializer
Assembly: Telerik.Reporting (in Telerik.Reporting.dll)
Syntax
The ReportXmlSerializer type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | ReportXmlSerializer |
Initializes a new instance of the ReportXmlSerializer class.
|
Methods
Name | Description | |
---|---|---|
![]() ![]() | Deserialize(Stream) |
Deserializes the XML document contained by the specified Stream.
|
![]() ![]() | Deserialize(TextReader) |
Deserializes the XML document contained by the specified TextReader.
|
![]() ![]() | Deserialize(String) |
Deserializes the XML document from the specified URI.
|
![]() ![]() | Deserialize(XmlReader) |
Deserializes the XML document contained by the specified XmlReader.
|
![]() ![]() | Serialize(Stream, Object) |
Serializes the specified value and writes the XML document to the specified Stream.
|
![]() ![]() | Serialize(TextWriter, Object) |
Serializes the specified value and writes the XML document to the specified TextWriter.
|
![]() ![]() | Serialize(String, Object) |
Serializes the specified value and writes the XML document to a file with the specified file name.
|
![]() ![]() | Serialize(XmlWriter, Object) |
Serializes the specified value and writes the XML document to the specified XmlWriter.
|
Examples
The following example demonstrates how to create a report definition, how to serialize and deserialize it in XML and the corresponding XML output.
Creating the 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;
Serialize the 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 the report definition from a file:
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); }
Serialized Report Definition in XML
<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>
Version Information
Supported in: 1.0.1