表示不用连接到报表服务器而在本地处理和呈现的报表。
继承层次结构
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 值,该值指示当子报告中出错时是否应显示详细消息。 |
页首
方法
页首
事件
名称 | 说明 | |
---|---|---|
![]() |
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) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。