[]
        
(Showing Draft Content)

GrapeCity.ActiveReports.Design.Designer.LoadReport

LoadReport Method

LoadReport(FileInfo)

Loads an existing report from the specified file into the designer.

Declaration
public void LoadReport(FileInfo fileInfo)
Parameters
Type Name Description
FileInfo fileInfo

FileInfo wrapper for the section or page report to load. The report file should be in XML format and compatible with the ActiveReports designer.

Remarks

This method opens a report from a file, allowing the user to edit the report's design within the ActiveReports designer environment. It supports both section and page report types. Ensure that the file specified by fileInfo exists and is accessible.

Exceptions
Type Condition
ArgumentNullException

Thrown when fileInfo is null.

FileNotFoundException

Thrown when the file specified in fileInfo does not exist.

LoadReport(Stream)

Loads an existing report from a stream into the designer. This method is obsolete.

Declaration
[Obsolete("This method has been deprecated. Please, use LoadReport(XmlReader,DesignerReportType) method instead")]
public void LoadReport(Stream stream)
Parameters
Type Name Description
Stream stream

A stream containing the report data. This can be either a section report or a page report.

LoadReport(XmlReader, DesignerReportType)

Loads an existing report of the specified type from the provided System.Xml.XmlReader into the designer.

Declaration
public void LoadReport(XmlReader reader, DesignerReportType type)
Parameters
Type Name Description
XmlReader reader

An System.Xml.XmlReader instance that reads the report XML data. This can be either a section report or a page report.

DesignerReportType type

The type of the report being loaded, specified by the DesignerReportType enumeration. This determines how the report is processed and displayed in the designer.

Remarks

This method allows for more flexible report loading by accepting an System.Xml.XmlReader, which can be used to load reports from various sources, including streams, strings, or files.

Examples

The following example demonstrates how to load a report from a string containing XML data:

var report = new PageReport {
	Report = {
		DataSources = {
			new DataSource {
				Name = "MainDataSource",
				ConnectionProperties = {
					ConnectString = "your_connection_string",
					DataProvider = "MSSQL",
				}
			}
		}
	}
};
//Serialize and load report into the designer
designer.LoadReport(XmlReader.Create(new StringReader(report.ToRdlString())), DesignerReportType.Rdl);

LoadReport(XmlReader, DesignerReportType, string)

Loads an existing report of the specified type and name from the provided System.Xml.XmlReader into the designer.

Declaration
public void LoadReport(XmlReader reader, DesignerReportType type, string reportName)
Parameters
Type Name Description
XmlReader reader

An System.Xml.XmlReader instance that reads the report XML data. This can be either a section report or a page report.

DesignerReportType type

The type of the report being loaded, specified by the DesignerReportType enumeration. This determines how the report is processed and displayed in the designer.

string reportName

The name of the report. This parameter can be used to specify a name for the report being loaded. If null or empty, the name may be derived from the XML content or remain unspecified.

Remarks

This overload of the LoadReport method provides an additional parameter for specifying the name of the report. This can be useful for identifying the report within the designer environment, especially when working with multiple reports or when the report's name is not defined within the XML structure.

Examples

The following example demonstrates how to load a report from a string containing XML data, specifying a name for the report:

// Assume that 'pageReport' is a PageReport object containing the report layout
using (var designer = new Designer())
{
	var xml = new StringBuilder();
	using (XmlWriter xmlWriter = XmlWriter.Create(xml))
		pageReport.Save(xmlWriter);
	using (XmlReader xmlReader = XmlReader.Create(new StringReader(xml.ToString())))
		designer.LoadReport(xmlReader, DesignerReportType.Page, "MyCustomReportName");
}