LocalReport 類別
代表未連接至報表伺服器而在本機處理及轉譯的報表。
繼承階層架構
Object
Microsoft.Reporting.WebForms.Report
Microsoft.Reporting.WebForms.LocalReport
命名空間: Microsoft.Reporting.WebForms
組件: Microsoft.ReportViewer.WebForms (在 Microsoft.ReportViewer.WebForms.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 Maps 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 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);
}
}
Protected Sub Button1_Click(ByVal sender As 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()
Dim lr As New Microsoft.Reporting.WebForms.LocalReport
lr.ReportPath = "C:\My Reports\Monthly Sales.rdlc"
lr.DataSources.Add(New ReportDataSource("Sales", GetSalesData()))
deviceInfo = _
"<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"
bytes = ReportViewer1.LocalReport.Render("Excel", deviceInfo,_
mimeType, encoding, extension, streamids, warnings)
Dim fs As New FileStream("c:\output.xls", FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
End Sub
執行緒安全
這個類型的任何 Public static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員是安全執行緒。