LocalReport 類別
發行︰ 2016年4月
代表未連接至報表伺服器而在本機處理及轉譯的報表。
命名空間: Microsoft.Reporting.WinForms
組件: Microsoft.ReportViewer.WinForms (於 Microsoft.ReportViewer.WinForms.dll)
繼承階層
System.Object
Microsoft.Reporting.WinForms.Report
Microsoft.Reporting.WinForms.LocalReport
語法
[SerializableAttribute]
public sealed class LocalReport : Report, ISerializable, IDisposable
[SerializableAttribute]
public ref class LocalReport sealed : Report, ISerializable,
IDisposable
[<Sealed>]
[<SerializableAttribute>]
type LocalReport =
class
inherit Report
interface ISerializable
interface IDisposable
end
<SerializableAttribute>
Public NotInheritable Class LocalReport
Inherits Report
Implements ISerializable, IDisposable
建構函式
名稱 | 描述 | |
---|---|---|
LocalReport() | 初始化 LocalReport 類別的新執行個體。 |
屬性
名稱 | 描述 | |
---|---|---|
DataSources | 取得報表所用的資料來源集合。 |
|
DisplayName | 取得或設定報表的顯示名稱。(繼承自 Report。) |
|
EnableExternalImages | 指出在報表有外部影像時,是否能轉譯報表。 |
|
EnableHyperlinks | 指出在報表含有超連結動作時,是否能轉譯報表。 |
|
IsDrillthroughReport | 指出報表是否為鑽研報表。(繼承自 Report。) |
|
IsReadyForRendering | 取得 Boolean 值,這個值表示報表定義和所有必要參數是否已指定,而且所有資料來源是否已準備好可供使用。(繼承自 Report。) |
|
MapTileServerConfiguration | 定義 Microsoft Bing Maps SOAP 服務的組態設定,為報表中的地圖報表項目提供圖格背景。 |
|
OriginalParametersToDrillthrough | 如果這個報表是鑽研報表,則傳回從父報表傳遞至這個報表的參數。 |
|
ReportEmbeddedResource | 取得或設定報表內嵌資源的名稱。 |
|
ReportPath | 取得或設定本機報表的檔案系統路徑。 |
|
ShowDetailedSubreportMessages | 取得或設定 boolean 值,此值可在子報表中發生錯誤時,指出是否應顯示詳細訊息。 |
方法
事件
名稱 | 描述 | |
---|---|---|
SubreportProcessing | 發生在處理子報表時。 |
明確介面實作
名稱 | 描述 | |
---|---|---|
ISerializable.GetObjectData(SerializationInfo, StreamingContext) |
註解
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
執行緒安全
此類型的任何 public static (在 Visual Basic 中 共用 在 Visual Basic 中) 成員皆為安全執行緒。不保證任何執行個體成員為安全執行緒。
另請參閱
Microsoft.Reporting.WinForms 命名空間
回到頁首