Export (0) Print
Expand All
2 out of 6 rated this helpful - Rate this topic

LocalReport Class

Represents a report that is processed and rendered locally without connecting to a report server.

Namespace: Microsoft.Reporting.WebForms
Assembly: Microsoft.ReportViewer.WebForms (in microsoft.reportviewer.webforms.dll)
[SerializableAttribute] 
public sealed class LocalReport : Report, ISerializable, IDisposable
/** @attribute SerializableAttribute() */ 
public final class LocalReport extends Report implements ISerializable, IDisposable
SerializableAttribute 
public final class LocalReport extends Report implements ISerializable, IDisposable

The LocalReport class represents reports that are processed and rendered locally without connecting to a report server. This class is the same object that is used by the ReportViewer control, but it also can be used independently as a non-visual object that encapsulates the core functionality of the ReportViewer control.

The LocalReport object can open client report definition (RDLC) files from the file system or from embedded resources, or the RDLC file can be supplied to it as a Stream or a TextReader.

The LocalReport object does not have the ability to execute queries or fetch data; instead data sources must be added to the DataSources collection property.

The LocalReport object supports report parameters, but does not support parameter prompts

In the following code example, a LocalReport object is used to load and export a report.

protected void Button1_Click(object sender, EventArgs e)
{

   Microsoft.Reporting.WebForms.LocalReport lr = 
     new Microsoft.Reporting.WebForms.LocalReport();

   string deviceInfo =
     "<DeviceInfo>" +
     "<SimplePageHeaders>True</SimplePageHeaders>" + 
     "</DeviceInfo>";

   lr.ReportPath = @"C:\My Reports\Monthly Sales.rdlc";

   lr.DataSources.Add(new ReportDataSource("Sales", GetSalesData()));

   byte[] bytes = lr.Render("Excel", deviceInfo, out mimeType, 
     out encoding, out streamids, out warnings);

      using (FileStream fs = new FileStream(@"c:\My Reports\Monthly Sales.xls", FileMode.Create))
      {
        fs.Write(bytes, 0, bytes.Length);
      }
}
System.Object
   Microsoft.Reporting.WebForms.Report
    Microsoft.Reporting.WebForms.LocalReport
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.