LocalReport 类

表示不用连接到报表服务器而在本地处理和呈现的报表。

继承层次结构

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

命名空间:  Microsoft.Reporting.WinForms
程序集:  Microsoft.ReportViewer.WinForms(在 Microsoft.ReportViewer.WinForms.dll 中)

语法

声明
<SerializableAttribute> _
Public NotInheritable Class LocalReport _
    Inherits Report _
    Implements ISerializable, IDisposable
[SerializableAttribute]
public sealed class LocalReport : Report, 
    ISerializable, IDisposable
[SerializableAttribute]
public ref class LocalReport sealed : public Report, 
    ISerializable, IDisposable
[<Sealed>]
[<SerializableAttribute>]
type LocalReport =  
    class
        inherit Report
        interface ISerializable
        interface IDisposable
    end
public final class LocalReport extends Report implements ISerializable, IDisposable

LocalReport 类型公开以下成员。

构造函数

  名称 说明
公共方法 LocalReport 初始化 LocalReport 类的新实例。

页首

属性

  名称 说明
公共属性 DataSources 获取报表使用的数据源集合。
公共属性 DisplayName 获取或设置报表的显示名称。 (继承自 Report。)
公共属性 EnableExternalImages 指示在报表包含外部图像时是否可以呈现。
公共属性 EnableHyperlinks 指示在报表包含超链接操作时是否可以呈现。
公共属性 IsDrillthroughReport 指示该报表是否为钻取报表。 (继承自 Report。)
公共属性 IsReadyForRendering 获取一个 Boolean 值,该值指示是否已指定报表定义及所有必需参数,以及是否所有数据源已经可供使用。 (继承自 Report。)
公共属性 MapTileServerConfiguration 定义 Microsoft Bing 地图 SOAP 服务的配置设置,它提供报表中地图报表项的图块背景。
公共属性 OriginalParametersToDrillthrough 返回从父报表传递到此报表(如果它是钻取报表)的参数。
公共属性 ReportEmbeddedResource 获取或设置嵌入报表的资源的名称。
公共属性 ReportPath 获取或设置本地报表的文件系统路径。
公共属性 ShowDetailedSubreportMessages 获取或设置一个 boolean 值,该值指示当子报告中出错时是否应显示详细消息。

页首

方法

  名称 说明
公共方法 AddFullTrustModuleInSandboxAppDomain 将提供的程序集添加到在沙盒应用程序域中以完全信任模式运行的程序集列表。
公共方法 AddTrustedCodeModuleInCurrentAppDomain 已废弃不用。 将提供的程序集添加至可以在当前 AppDomain 中执行的程序集列表。
公共方法 Dispose 释放由 LocalReport 对象使用的所有资源。
公共方法 Equals 确定指定的对象是否等于当前对象。 (继承自 Object。)
公共方法 ExecuteReportInCurrentAppDomain 已废弃不用。 导致在当前 AppDomain 中执行报告中的处理扩展插件和表达式。
公共方法 ExecuteReportInSandboxAppDomain 已废弃不用。 导致处理扩展插件和表达式在具有有限权限的应用程序域中运行。
公共方法 GetDataSourceNames 返回本地报表中使用的所有数据集的名称。
公共方法 GetDefaultPageSettings 获取在本地报表中指定的默认页设置。 (重写 Report.GetDefaultPageSettings()。)
公共方法 GetDocumentMap 返回本地报表的文档结构图的表示形式。 (继承自 Report。)
公共方法 GetHashCode 作为默认哈希函数。 (继承自 Object。)
公共方法 GetParameters 返回该报告的报告参数属性。 (重写 Report.GetParameters()。)
公共方法 GetTotalPages() 返回报表中的软页总数。 (继承自 Report。)
公共方法 GetTotalPages(PageCountMode%) 返回报告中的软页总数以及用于指示当前页计数模式的 PageCountMode 枚举值。 (重写 Report.GetTotalPages(PageCountMode%)。)
公共方法 GetType 获取当前实例的 Type。 (继承自 Object。)
公共方法 ListRenderingExtensions 返回本地报表的所有可用的呈现扩展插件。 (重写 Report.ListRenderingExtensions()。)
公共方法 LoadReportDefinition(TextReader) 使用 TextReader 从本地文件系统加载报告定义。 (重写 Report.LoadReportDefinition(TextReader)。)
公共方法 LoadReportDefinition(Stream) 使用 Stream 加载要处理的报表定义。 (继承自 Report。)
公共方法 LoadSubreportDefinition(String, Stream) 使用 Stream 加载子报告定义。
公共方法 LoadSubreportDefinition(String, TextReader) 使用 TextReader 加载子报告定义。
公共方法 Refresh 导致用新数据呈现本地报表。 (重写 Report.Refresh()。)
公共方法 ReleaseSandboxAppDomain 使 LocalReport 对象立即释放对沙盒应用程序域的引用。
公共方法 Render(String) 处理报表并以指定的格式呈现该报表。 (继承自 Report。)
公共方法 Render(String, String) 处理报表并以指定的格式呈现该报表。 (继承自 Report。)
公共方法 Render(String, String, CreateStreamCallback, array<Warning[]%) 处理报表,并使用回调函数提供的流以指定的格式呈现报表。
公共方法 Render(String, String, PageCountMode, CreateStreamCallback, array<Warning[]%) 使用指定页计数模式处理报表,并使用回调函数提供的流以指定格式呈现报表。
公共方法 Render(String, String, String%, String%, String%, array<String[]%, array<Warning[]%) 处理报表并以指定的格式呈现该报表。 (继承自 Report。)
公共方法 Render(String, String, PageCountMode, String%, String%, String%, array<String[]%, array<Warning[]%) 以指定页计数模式处理报表,并以指定格式呈现报表。 (重写 Report.Render(String, String, PageCountMode, String%, String%, String%, array<String[]%, array<Warning[]%)。)
公共方法 SetBasePermissionsForSandboxAppDomain 使用提供的权限集设置沙盒应用程序域的基本权限。
公共方法 SetParameters(IEnumerable<ReportParameter>) 设置本地报表的报表参数属性。 (重写 Report.SetParameters(IEnumerable<ReportParameter>)。)
公共方法 SetParameters(ReportParameter) 设置报表的报表参数属性。 (继承自 Report。)
公共方法 ToString 返回表示当前对象的字符串。 (继承自 Object。)

页首

事件

  名称 说明
公共事件 SubreportProcessing 在处理子报表时发生。

页首

显式接口实现

  名称 说明
显式接口实现私有方法 ISerializable.GetObjectData

页首

备注

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 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.

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);
      }
}
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)

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

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参阅

参考

Microsoft.Reporting.WinForms 命名空间