第 1 課:建立報表伺服器專案 (Reporting Services)

在這一課中,您會使用報表設計師建立報表伺服器專案報表定義 (.rdl) 檔案。

注意

SQL Server Data Tools (SSDT) 是建立商業智慧解決方案的 Microsoft Visual Studio 環境。 SSDT 為報表設計師提供了撰寫環境,您可在此開啟、修改、預覽、儲存及部署 Reporting Services 編頁報告定義、共用的資料來源、共用資料集與報表組件。

報表組件在 SQL Server Reporting Services 2019 之後的所有 SQL Server Reporting Services 版本中均已退場,並自 SQL Server Reporting Services 2022 和 Power BI 報表伺服器起中止。

當您使用報表設計師建立報表時,它會建立一個報表伺服器專案,其中包含報表檔案和報表所使用的其他資源檔案。

建立報表伺服器專案

  1. 從 [檔案] 功能表選取 [新增] >[專案] 。

    Screenshot of Visual Studio showing the project option selected in the new dropdown menu in the file menu.

  2. 在最左邊資料行的 [已安裝] 底下,選取 [Reporting Services] 。 在某些情況下,它可能會在 [Business Intelligence] 群組底下。

    Screenshot of the New Project dialog box showing Reporting Services selected and the Report Server Project template highlighted.

    重要

    若是 Visual Studio (VS),如果您沒有在左側資料行中看到 Reporting Services,則會安裝 SSDT 工作負載來新增報表設計師。 從 [工具] 功能表上,選取 [取得工具與功能...] ,然後從顯示的工作負載中選取 [SQL Server Data Tools] 。 如果您沒有在中間資料行中看到報表服務物件,請新增 Reporting Services 擴充功能。 從 [工具] 功能表上,選取 [擴充功能和更新] >[線上] 。 在中間資料行中,從顯示的擴充功能選取 [Microsoft Reporting Services 專案] >[下載] 。 對於 SSDT,請參閱下載 SQL Server Data Tools (SSDT)。 在 Visual Studio 2019 中,如果前述步驟無法運作,請嘗試安裝 Microsoft Reporting Services Project 延伸模組

  3. 在 [新增專案] 對話方塊的中間資料行中,選取報表伺服器專案圖示

  4. 在 [名稱] 文字方塊中,輸入 "Tutorial" 作為專案名稱。 [位置] 文字輸入框預設會顯示您的 "Documents\Visual Studio 20xx\Projects" 資料夾路徑。 報表設計師會在此路徑底下建立一個名為 Tutorial 的資料夾,然後在此資料夾中建立 Tutorial 專案。 如果專案不屬於 VS 方案,則 VS 也會建立一個方案檔 (.sln)。

  5. 選取 [確定] 可建立專案。 Tutorial 專案會顯示在右邊的 [方案總管] 窗格中。

建立報表定義檔案 (RDL)

  1. 在 [方案總管] 窗格中,以滑鼠右鍵按一下 [報表] 資料夾。 如果您沒有看到 [方案總管] 窗格,請選取 [檢視] 功能表 > [方案總管]。

  2. 選取 [新增]>[新項目]。

    Screenshot of the Solution Explorer showing the Add option selected on the Reports context menu.

  3. 在 [加入新項目] 視窗中,選取 [報表] 圖示。

  4. 在 [名稱] 文字方塊中輸入 "Sales Orders.rdl"。

  5. 選取 [加入新項目] 對話方塊右下方的 [新增] 按鈕,即可完成此程序。 報表設計師會在 [設計] 檢視中開啟並顯示 Sales Orders 報表檔案。

    Screenshot of Visual Studio showing the Report Designer and the Sales Orders report in Design view.

後續步驟

在本課中,您已經建立了 Tutorial 報表專案和 Sales Orders 報表。 在其餘的課程中,您將了解如何:

  • 設定報表的資料來源。
  • 從資料來源建立資料集。
  • 設計報表版面配置並設定其格式。

請繼續第 2 課:指定連線資訊 (Reporting Services)