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

建構函式

名稱 描述
System_CAPS_pubmethod LocalReport()

初始化 LocalReport 類別的新執行個體。

屬性

名稱 描述
System_CAPS_pubproperty DataSources

取得報表所用的資料來源集合。

System_CAPS_pubproperty DisplayName

取得或設定報表的顯示名稱。(繼承自 Report。)

System_CAPS_pubproperty EnableExternalImages

指出在報表有外部影像時,是否能轉譯報表。

System_CAPS_pubproperty EnableHyperlinks

指出在報表含有超連結動作時,是否能轉譯報表。

System_CAPS_pubproperty IsDrillthroughReport

指出報表是否為鑽研報表。(繼承自 Report。)

System_CAPS_pubproperty IsReadyForRendering

取得 Boolean 值,這個值表示報表定義和所有必要參數是否已指定,而且所有資料來源是否已準備好可供使用。(繼承自 Report。)

System_CAPS_pubproperty MapTileServerConfiguration

定義 Microsoft Bing Maps SOAP 服務的組態設定,為報表中的地圖報表項目提供圖格背景。

System_CAPS_pubproperty OriginalParametersToDrillthrough

如果這個報表是鑽研報表,則傳回從父報表傳遞至這個報表的參數。

System_CAPS_pubproperty ReportEmbeddedResource

取得或設定報表內嵌資源的名稱。

System_CAPS_pubproperty ReportPath

取得或設定本機報表的檔案系統路徑。

System_CAPS_pubproperty ShowDetailedSubreportMessages

取得或設定 boolean 值,此值可在子報表中發生錯誤時,指出是否應顯示詳細訊息。

方法

名稱 描述
System_CAPS_pubmethod AddFullTrustModuleInSandboxAppDomain(StrongName)

將提供的組件加入至完全信任模式下,在沙箱應用程式定義域中執行的組件清單。

System_CAPS_pubmethod AddTrustedCodeModuleInCurrentAppDomain(String)

已淘汰。將提供的組件加入至受信任可以執行在目前的組件清單 AppDomain

System_CAPS_pubmethod Dispose()

釋放 LocalReport 物件所使用的全部資源。

System_CAPS_pubmethod Equals(Object)

(繼承自 Object。)

System_CAPS_pubmethod ExecuteReportInCurrentAppDomain(Evidence)

已淘汰。處理延伸模組與報表中的運算式,會使執行目前 AppDomain

System_CAPS_pubmethod ExecuteReportInSandboxAppDomain()

已淘汰。處理延伸模組與運算式,以有限權限的應用程式定義域中執行的原因。

System_CAPS_pubmethod GetDataSourceNames()

傳回本機報表內所用的所有資料集名稱。

System_CAPS_pubmethod GetDefaultPageSettings()

取得預設的本機報表所指定的頁面設定。(覆寫 Report.GetDefaultPageSettings()。)

System_CAPS_pubmethod GetDocumentMap()

傳回本機報表之文件引導模式的表示法。(繼承自 Report。)

System_CAPS_pubmethod GetHashCode()

(繼承自 Object。)

System_CAPS_pubmethod GetParameters()

傳回報表的報表參數屬性。(覆寫 Report.GetParameters()。)

System_CAPS_pubmethod GetTotalPages()

傳回報表中的軟分頁總數。(繼承自 Report。)

System_CAPS_pubmethod GetTotalPages(PageCountMode)

傳回報表中軟分頁的總數,以及指出現有頁面計數模式的 PageCountMode 列舉值。(覆寫 Report.GetTotalPages(PageCountMode)。)

System_CAPS_pubmethod GetType()

(繼承自 Object。)

System_CAPS_pubmethod ListRenderingExtensions()

傳回本機報表所有可用的轉譯延伸模組。(覆寫 Report.ListRenderingExtensions()。)

System_CAPS_pubmethod LoadReportDefinition(Stream)

使用 Stream 載入要進行處理的報表定義。(繼承自 Report。)

System_CAPS_pubmethod LoadReportDefinition(TextReader)

從本機檔案系統使用 TextReader 載入報表定義。(覆寫 Report.LoadReportDefinition(TextReader)。)

System_CAPS_pubmethod LoadSubreportDefinition(String, Stream)

使用 Stream 載入子報表定義。

System_CAPS_pubmethod LoadSubreportDefinition(String, TextReader)

使用 TextReader 載入子報表定義。

System_CAPS_pubmethod Refresh()

使本機報表利用新資料來進行轉譯。(覆寫 Report.Refresh()。)

System_CAPS_pubmethod ReleaseSandboxAppDomain()

會導致 LocalReport 物件立即釋放其沙箱應用程式定義域的參考。

System_CAPS_pubmethod Render(String)

處理報表並依照指定的格式轉譯它。(繼承自 Report。)

System_CAPS_pubmethod Render(String, String)

處理報表並依照指定的格式轉譯它。(繼承自 Report。)

System_CAPS_pubmethod Render(String, String, CreateStreamCallback, Warning[])

處理報表,並利用回呼函式所提供的資料流,依照指定的格式來轉譯它。

System_CAPS_pubmethod Render(String, String, PageCountMode, CreateStreamCallback, Warning[])

使用指定頁面計數模式處理報表,並利用回呼函式所提供的資料流,依照指定的格式來轉譯它。

System_CAPS_pubmethod Render(String, String, PageCountMode, String, String, String, String[], Warning[])

使用指定的頁面計數模式來處理報表,並依照指定的格式轉譯該報表。(覆寫 Report.Render(String, String, PageCountMode, String, String, String, String[], Warning[])。)

System_CAPS_pubmethod Render(String, String, String, String, String, String[], Warning[])

處理報表並依照指定的格式轉譯它。(繼承自 Report。)

System_CAPS_pubmethod SetBasePermissionsForSandboxAppDomain(PermissionSet)

使用提供的權限集合,設定沙箱應用程式定義域的基本權限。

System_CAPS_pubmethod SetParameters(IEnumerable<ReportParameter>)

設定本機報表的報表參數屬性。(覆寫 Report.SetParameters(IEnumerable<ReportParameter>)。)

System_CAPS_pubmethod SetParameters(ReportParameter)

設定報表的報表參數屬性。(繼承自 Report。)

System_CAPS_pubmethod ToString()

(繼承自 Object。)

事件

名稱 描述
System_CAPS_pubevent SubreportProcessing

發生在處理子報表時。

明確介面實作

名稱 描述
System_CAPS_pubinterfaceSystem_CAPS_privmethod 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 命名空間

回到頁首