# GrapeCity.ActiveReports.Design.Designer.LoadReport

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport*">LoadReport Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_ActiveReports_Design_Designer_LoadReport_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport*"></a>
<h4 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_IO_FileInfo_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport(System.IO.FileInfo)">LoadReport(FileInfo)</h4>
<div class="markdown level1 summary"><p>Loads an existing report from the specified file into the designer.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadReport(FileInfo fileInfo)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.fileinfo">FileInfo</a></td>
      <td><span class="parametername">fileInfo</span></td>
      <td><p>FileInfo wrapper for the section or page report to load. The report file should be in XML format and compatible with the
ActiveReports designer.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_IO_FileInfo__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>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 <code class="paramref">fileInfo</code> exists and is accessible.</p>
</div>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Condition</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.argumentnullexception">ArgumentNullException</a></td>
      <td><p>Thrown when <code class="paramref">fileInfo</code> is null.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.filenotfoundexception">FileNotFoundException</a></td>
      <td><p>Thrown when the file specified in <code class="paramref">fileInfo</code> does not exist.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="GrapeCity_ActiveReports_Design_Designer_LoadReport_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport*"></a>
<h4 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_IO_Stream_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport(System.IO.Stream)">LoadReport(Stream)</h4>
<div class="markdown level1 summary"><p>Loads an existing report from a stream into the designer. This method is obsolete.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">[Obsolete(&quot;This method has been deprecated. Please, use LoadReport(XmlReader,DesignerReportType) method instead&quot;)]
public void LoadReport(Stream stream)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>A stream containing the report data. This can be either a section report or a page report.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="GrapeCity_ActiveReports_Design_Designer_LoadReport_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport*"></a>
<h4 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_Xml_XmlReader_GrapeCity_ActiveReports_Design_DesignerReportType_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport(System.Xml.XmlReader,GrapeCity.ActiveReports.Design.DesignerReportType)">LoadReport(XmlReader, DesignerReportType)</h4>
<div class="markdown level1 summary"><p>Loads an existing report of the specified type from the provided <span class="xref">System.Xml.XmlReader</span> into the designer.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadReport(XmlReader reader, DesignerReportType type)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="xref">XmlReader</span></td>
      <td><span class="parametername">reader</span></td>
      <td><p>An <span class="xref">System.Xml.XmlReader</span> instance that reads the report XML data. This can be either a section report or a page report.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.ActiveReports.Design.DesignerReportType.html">DesignerReportType</a></td>
      <td><span class="parametername">type</span></td>
      <td><p>The type of the report being loaded, specified by the <a class="xref" href="GrapeCity.ActiveReports.Design.DesignerReportType.html">DesignerReportType</a> enumeration. This determines how the report
is processed and displayed in the designer.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_Xml_XmlReader_GrapeCity_ActiveReports_Design_DesignerReportType__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method allows for more flexible report loading by accepting an <span class="xref">System.Xml.XmlReader</span>, which can be used to load reports from various sources,
including streams, strings, or files.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_Xml_XmlReader_GrapeCity_ActiveReports_Design_DesignerReportType__examples">Examples</h5>
<p>The following example demonstrates how to load a report from a string containing XML data:</p>
<pre><code class="lang-csharp">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);</code></pre>



<a id="GrapeCity_ActiveReports_Design_Designer_LoadReport_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport*"></a>
<h4 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_Xml_XmlReader_GrapeCity_ActiveReports_Design_DesignerReportType_System_String_" data-uid="GrapeCity.ActiveReports.Design.Designer.LoadReport(System.Xml.XmlReader,GrapeCity.ActiveReports.Design.DesignerReportType,System.String)">LoadReport(XmlReader, DesignerReportType, string)</h4>
<div class="markdown level1 summary"><p>Loads an existing report of the specified type and name from the provided <span class="xref">System.Xml.XmlReader</span> into the designer.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadReport(XmlReader reader, DesignerReportType type, string reportName)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="xref">XmlReader</span></td>
      <td><span class="parametername">reader</span></td>
      <td><p>An <span class="xref">System.Xml.XmlReader</span> instance that reads the report XML data. This can be either a section report or a page report.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.ActiveReports.Design.DesignerReportType.html">DesignerReportType</a></td>
      <td><span class="parametername">type</span></td>
      <td><p>The type of the report being loaded, specified by the <a class="xref" href="GrapeCity.ActiveReports.Design.DesignerReportType.html">DesignerReportType</a> enumeration. This determines how the report
is processed and displayed in the designer.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">reportName</span></td>
      <td><p>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.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_Xml_XmlReader_GrapeCity_ActiveReports_Design_DesignerReportType_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This overload of the <code>LoadReport</code> 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.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Design_Designer_LoadReport_System_Xml_XmlReader_GrapeCity_ActiveReports_Design_DesignerReportType_System_String__examples">Examples</h5>
<p>The following example demonstrates how to load a report from a string containing XML data, specifying a name for the report:</p>
<pre><code class="lang-csharp">// 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");
}</code></pre>

</div>
