LocalReport 클래스

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

네임스페이스: Microsoft.Reporting.WinForms
어셈블리: microsoft.reportviewer.winforms.dll의 Microsoft.ReportViewer.WinForms

구문

주의

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 nonvisual 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 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 must be supplied to it as instances of ADO.NET DataTables or as a collection of business objects.

The LocalReport object supports report parameters, but does not support query parameters.

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

private void button1_Click(object sender, EventArgs e)
{

   Microsoft.Reporting.WinForms.LocalReport lr = new Microsoft.Reporting.WinForms.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);
        fs.Close();
      }
}
Private Sub Button1_Click(ByVal sender As System.Object, _
   ByVal e As System.EventArgs) Handles Button1.Click
   Dim warnings As Warning() = Nothing
   Dim streamids As String() = Nothing
   Dim mimeType As String = Nothing
   Dim encoding As String = Nothing
   Dim extension As String = Nothing
   Dim deviceInfo as string
   Dim bytes As Byte()

   deviceInfo = "< deviceInfo ><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"

   bytes = ReportViewer1.LocalReport.Render("Excel", Nothing, _
     mimeType,encoding, extension, streamids, warnings)

   Dim fs As New FileStream("c:\output.xls", FileMode.Create)
   fs.Write(bytes, 0, bytes.Length)
   fs.Close()

   MessageBox.Show("Report exported to output.xls", "Info")
End Sub

상속 계층 구조

System.Object
   Microsoft.Reporting.WinForms.Report
    Microsoft.Reporting.WinForms.LocalReport

스레드 보안

이 유형의 모든 public static(Visual Basic의 Shared) 멤버는 스레드로부터 안전합니다. 인스턴스 멤버는 스레드로부터의 안전성이 보장되지 않습니다.

참고 항목

참조

LocalReport 멤버
Microsoft.Reporting.WinForms 네임스페이스