資料表、矩陣和清單 (報表產生器及 SSRS)Tables, Matrices, and Lists (Report Builder and SSRS)

Reporting ServicesReporting Services,資料表、 矩陣和清單都是資料區域顯示分頁報表中會組織成資料列和資料行的資料格的資料。In Reporting ServicesReporting Services, tables, matrices, and lists are data regions that display paginated report data in cells that are organized into rows and columns. 資料格通常包含文字資料 (例如文字、日期和數字),但也可以包含量測計、圖表或報表項目 (例如影像)。The cells typically contain text data such as text, dates, and numbers but they can also contain gauges, charts, or report items such as images. 資料表、矩陣和清單經常統稱為 Tablix 資料區。Collectively, tables, matrices, and lists are frequently referred to as tablix data regions.

資料表、矩陣和清單範本建立於 Tablix 資料區之上,是一個可以在資料格中顯示資料的彈性方格。The table, matrix, and list templates are built on the tablix data region, which is a flexible grid that can display data in cells. 在資料表和矩陣範本中,資料格會組織成資料列和資料行。In the table and matrix templates, cells are organized into rows and columns. 範本是基礎泛型 tablix 資料區的變化,您可以結合範本格式顯示資料,並將資料表、 矩陣或清單上變更為包含其他資料區的功能,當您開發您的報表。Because templates are variations of the underlying generic tablix data region, you can display data in combination of template formats and change the table, matrix, or list on to include the features of another data region as you develop your report. 例如,如果您加入一個資料表之後,發現該資料表不符合您的需要,您可以加入資料行群組,讓該資料表變成矩陣。For example, if you add a table and find it does not serve your needs, you can add column groups to make the table a matrix.

資料表和矩陣資料區可以加入巢狀資料表、矩陣、清單、圖表和量測計,以顯示複雜的資料關聯性。The table and matrix data regions can display complex data relationships by including nested tables, matrices, lists, charts and gauges. 資料表和矩陣具有表格式配置,且其資料來自單一資料來源上建立的單一資料集。Tables and matrices have a tabular layout and their data comes from a single dataset, built on a single data source. 資料表和矩陣之間的主要差異在於資料表可以只包含資料列群組,而矩陣則包含資料列群組和資料行群組。The key difference between tables and matrices is that tables can include only row groups, where as matrices have row groups and column groups.

清單則稍有不同。Lists are a little different. 它們支援自由形式的配置,而且可以包含多個對等的資料表或矩陣,每個都使用來自不同資料集的資料。They support a free-layout that and can include multiple peer tables or matrices, each using data from a different dataset. 清單也可以用於表單,例如發票。Lists can also be used for forms, such as invoices.

下圖顯示包含資料表、矩陣或清單的簡單報表。The following pictures show simple reports with a table, matrix, or list.

RS_TableMatrixListRS_TableMatrixList

若要快速地開始使用資料表、矩陣和清單,請參閱教學課程:建立基本資料表報表 (報表產生器)教學課程:建立矩陣報表 (報表產生器)教學課程:建立自由格式報表 (報表產生器)To quickly get started with tables, matrices, and lists, see Tutorial: Creating a Basic Table Report (Report Builder), Tutorial: Creating a Matrix Report (Report Builder), and Tutorial: Creating a Free Form Report (Report Builder).

注意

您可以將資料表、矩陣和清單當做報表組件,與報表分開發行。You can publish tables, matrices, and lists separately from a report as report parts. 深入了解 報表組件Read more about Report Parts.

Table Table

使用資料表顯示詳細資料、在資料列群組中組織資料,或兩者。Use a table to display detail data, organize the data in row groups, or both. 「資料表」範本包含三個資料行,其中有一個資料的資料表頁首資料列和一個詳細資料資料列。The Table template contains three columns with a table header row and a details row for data. 下圖顯示在設計介面上選取的初始資料表範本:The following figure shows the initial table template, selected on the design surface:

資料表範本設計介面上,選取Table template on design surface, selected

您可以依單一欄位、多個欄位或透過撰寫自己的運算式來分組資料。You can group data by a single field, by multiple fields, or by writing your own expression. 您可以建立巢狀群組或獨立的相鄰群組,以及顯示群組資料的彙總值,或將總計加入至群組。You can create nested groups or independent, adjacent groups and display aggregated values for grouped data, or add totals to groups. 例如,如果您的資料表有一個稱為 [Category] 的資料列群組,您可以加入每個群組的小計,以及報表的總計。For example, if your table has a row group called [Category], you can add a subtotal for each group as well as a grand total for the report. 若要改善資料表的外觀,並反白顯示您想要強調的資料,您可以合併資料格,並將格式套用至資料和資料表標題。To improve the appearance of the table and highlight data you want to emphasize, you can merge cells and apply formatting to data and table headings.

您可以一開始隱藏詳細資料或群組資料並加入向下鑽研切換,以便讓使用者以互動方式選擇要顯示多少資料。You can initially hide detail or grouped data, and include drilldown toggles to enable a user to interactively choose how much data to show.

如需詳細資訊,請參閱資料表 (報表產生器及 SSRS)For more information, see Tables (Report Builder and SSRS).

矩陣 Matrix

使用矩陣顯示在資料列與資料行中群組的彙總資料摘要,類似於樞紐分析表或交叉資料表。Use a matrix to display aggregated data summaries, grouped in rows and columns, similar to a PivotTable or crosstab. 群組的資料列數和資料行數,取決於每個資料列和資料行群組的唯一組數目。The number of rows and columns for groups is determined by the number of unique values for each row and column groups. 下圖顯示在設計介面上選取的初始矩陣範本:The following figure shows the initial matrix template, selected on the design surface:

從 [工具箱] 中,選取加入新的矩陣New Matrix added from Toolbox, selected

您可以依資料列和資料行群組中的多個欄位或運算式群組資料。You can group data by multiple fields or expressions in row and column groups. 當報表資料和資料區在執行階段結合時,如果為資料行群組加入資料行,並為資料列群組加入資料列,則矩陣會在頁面上以水平和垂直方式成長。At run time, when the report data and data regions are combined, a matrix grows horizontally and vertically on the page as columns for column groups and rows for row groups are added. 矩陣資料格會顯示資料格所屬資料列與資料行群組交集範圍內的彙總值。The matrix cells display aggregate values that are scoped to the intersection of the row and column groups to which the cell belongs. 例如,如果您的矩陣有一個資料列群組 (Category) 和兩個資料行群組 (Territory 和 Year) 顯示銷售量的總和,報表會針對 Category 群組中的每個值,顯示包含銷售量總和的兩個資料格。For example, if your matrix has a row group (Category) and two column groups (Territory and Year) that display the sum of sales, the report displays two cells with sums of sales for each value in the Category group. 資料格範圍的兩個交集是:Category 和 Territory,以及 Category 和 Year。The scope of the cells are the two intersections are: Category and Territory and Category and Year. 矩陣可以包含巢狀群組與相鄰的群組。The matrix can include nested and adjacent groups. 巢狀群組擁有父子式關聯性,而相鄰的群組則擁有對等關聯性。Nested groups have a parent-child relationship and adjacent groups a peer relationship. 您可以針對矩陣內的任何和所有層級的巢狀資料列和資料行群組加入小計。You can add subtotals for any and all levels of nested row and column groups within the matrix.

若要讓矩陣資料更容易讀取,並反白顯示您想要強調的資料,您可以合併資料格,或以水平和垂直方式分割,然後將格式套用至資料和群組標題。To make the matrix data more readable and highlight the data you want to emphasize, you can merge cells or split horizontally and vertically and apply formatting to data and group headings.

您也可以加入一開始隱藏詳細資料的向下鑽研切換,使用者就可以在需要時,按一下切換來顯示更多或更少的詳細資料。You can also include drilldown toggles that initially hide detail data; the user can then click the toggles to display more or less detail as needed.

如需詳細資訊,請參閱 建立矩陣For more information, see Create a Matrix.

清單 List

使用清單來建立自由形式配置。Use a list to create a free-form layout. 您不會受限於格線配置,但是可以將欄位任意放在清單內。You are not limited to a grid layout, but can place fields freely inside the list. 您可以使用清單來設計顯示許多資料集欄位的表單,或將表單設計為容器來並排顯示群組資料的多個資料區域。You can use a list to design a form for displaying many dataset fields or as a container to display multiple data regions side by side for grouped data. 例如,您可以定義清單的群組;加入資料表、圖表與影像;以及以資料表和圖形形式顯示每個群組值的值,如同您針對員工或病患記錄所進行的處理。For example, you can define a group for a list; add a table, chart, and image; and display values in table and graphic form for each group value, as you might for an employee or patient record.

從 [工具箱] 中,選取加入新清單New List added from Toolbox, selected

如需詳細資訊,請參閱<使用清單建立發票和表單>。For more information, see [Create Invoices and Forms with Lists].

準備資料 Preparing Data

資料表、矩陣和清單資料區都會顯示資料集中的資料。A table, matrix, and list data regions display data from a dataset. 您可以在擷取資料集之資料的查詢中準備資料,也可以透過設定資料表、矩陣或清單中的屬性來準備資料。You can prepare the data in the query that retrieves the data for the dataset or by setting properties in the table, matrix, or list.

您用來擷取報表資料集之資料的查詢語言 (例如 Transact-SQLTransact-SQL) 可以透過套用篩選以便只包含資料的子集、以使報表更容易讀取的常數取代 Null 值或空白,以及排序和分組資料,來準備資料。The query languages such as Transact-SQLTransact-SQL, that you use to retrieve the data for the report datasets can prepare the data by applying filters to include only a subset of the data, replacing null values or blanks with constants that make the report more readable, and sorting and grouping data.

如果您選擇在報表的資料表、矩陣或清單資料區中準備資料,您要在資料區上或資料區內的資料格上設定屬性。If you choose to prepare the data in the table, matrix, or list data region of a report, you set properties on the data region or cells within the data region. 如果您想要篩選或排序資料,請在資料區上設定屬性。If you want to filter or sort the data, set the properties on the data region. 例如,若要排序資料,您要指定排序所依據的資料行和排序方向。For example, to sort the data you specify the columns to sort on and the sort direction. 如果您想要為某個欄位提供一個替代值,您要設定顯示該欄位之資料格文字的值。If you want to provide an alternative value for a field, you set the values of the cell text that displays the field. 例如,若要在欄位空白或 Null 時顯示空白,您要使用運算式來設定值。For example, to display Blank when a field is empty or null, you use an expression to set the value.

如需詳細資訊,請參閱準備要在 Tablix 資料區中顯示的資料 (報表產生器及 SSRS)For more information, see Preparing Data for Display in a Tablix Data Region (Report Builder and SSRS).

建立和設定資料表、矩陣或清單 Building and Configuring a Table, Matrix, or List

當您將資料表或矩陣加入至報表時,可以使用「資料表和矩陣精靈」或從報表產生器和報表設計師所提供的範本手動建立它們。When you add tables or matrices to your report, you can use the Table and Matrix Wizard or build them manually from the templates that Report Builder and Report Designer provide. 清單是從清單範本手動建立。Lists are built manually from the list template.

此精靈會引導您進行快速建立和設定資料表或矩陣的步驟。The wizard guides you through the steps to quickly build and configure a table or matrix. 完成精靈之後,或者如果您要從頭開始建立 Tablix 資料區,您可以進一步設定並精簡它們。After you complete the wizard or if you build the tablix data regions from scratch, you can further configure and refine them. 可從資料區的滑鼠右鍵功能表取得的對話方塊可讓您輕鬆設定常用的分頁符號屬性、頁首與頁尾的重複性和可見性、顯示選項、篩選,以及排序。The dialog boxes, available from the right-click menus on the data regions, make it easy to set the most commonly used properties for page breaks, repeatability and visibility of headers and footers, display options, filters, and sorting. 但是,Tablix 資料區會提供其他豐富的屬性,這些屬性只能在報表產生器的 [屬性] 窗格中設定。But the tablix data region provides a wealth of additional properties, which you can set only in the Properties pane of Report Builder. 例如,如果您要在資料表、矩陣或清單的資料集空白時顯示訊息,您要在 [屬性] 窗格的 NoRowsMessage Tablix 屬性中指定訊息文字。For example, if you want to display a message when the dataset for a table, matrix, or list is empty, you specify the message text in the NoRowsMessage tablix property in the Properties pane.

切換 Tablix 範本 Changing Between Tablix Templates

您不會受到一開始選擇的 Tablix 範本所限制。You are not limited by your initial tablix template choice. 當您加入群組、總計與標籤時,可以修改您的 Tablix 設計。As you add groups, totals, and labels, you might want to modify your tablix design. 例如,您可以從資料表開始,然後刪除詳細資料資料列並加入資料行群組。For example, you might start with a table and then delete the details row and add column groups. 如需詳細資訊,請參閱探索 Tablix 資料區的彈性 (報表產生器和 SSRS)For more information, see Exploring the Flexibility of a Tablix Data Region (Report Builder and SSRS).

您可以加入任何 Tablix 功能以便繼續開發資料表、矩陣或清單。You can continue to develop a table, matrix, or list by adding any tablix feature. Tablix 功能包括在資料列和資料行上顯示群組資料的詳細資料或彙總。Tablix features include displaying detail data or aggregates for grouped data on rows and columns. 您可以建立巢狀群組、獨立的相鄰群組或遞迴群組。You can create nested groups, independent adjacent groups, or recursive groups. 您可以在群組定義中加入多個群組運算式,藉以篩選與排序群組資料,並輕鬆地結合群組。You can filter and sort grouped data, and easily combine groups by including multiple group expressions in a group definition

您也可以加入群組的總計或資料區的總計。You can also add totals for a group or grand totals for the data region. 您可以隱藏資料列或資料行來簡化報表,並讓使用者切換隱藏資料的顯示,如同在向下鑽研報表中一樣。You can hide rows or columns to simplify a report and enable the user to toggle the display of the hidden data, as in a drilldown report. 如需詳細資訊,請參閱 控制報表頁面上的 Tablix 資料區顯示 (報表產生器及 SSRS)For more information, see Controlling the Tablix Data Region Display on a Report Page (Report Builder and SSRS).

如何主題 How-To Topics

本節列出向您逐步示範如何在報表中使用資料表、矩陣和清單;如何顯示資料列和資料行中的資料、加入和刪除資料行、合併資料格,以及加入資料列和資料行群組之小計的程序。This section lists procedures that show you, step by step, how to work with work with tables, matrices and lists in your reports; how to display data in rows and columns, add and delete columns, merge cells, and include subtotals for row and column groups.

本節內容 In This Section

下列主題提供有關使用 Tablix 資料區的其他資訊。The following topics provide additional information about working with the tablix data region.

Tablix 資料區 (報表產生器及 SSRS)Tablix Data Region (Report Builder and SSRS)
說明與 Tablix 資料區相關的主要概念,例如 Tablix 的區域、詳細資料和群組資料、資料行和資料列群組,以及靜態與動態資料列和資料行。Explains key concepts related to the tablix data region such as areas of the tablix, detail and grouped data, column and row groups, and static and dynamic rows and columns.

將資料加入至 Tablix 資料區 (報表產生器及 SSRS)Adding Data to a Tablix Data Region (Report Builder and SSRS)
提供有關將詳細資料和群組資料、小計和總計,以及標籤加入至 Tablix 資料區的詳細資訊。Provides detailed information about adding detail and grouped data, subtotals and totals, and labels to a tablix data region.

控制報表頁面上的 Tablix 資料區顯示 (報表產生器及 SSRS)Controlling the Tablix Data Region Display on a Report Page (Report Builder and SSRS)
描述 Tablix 資料區的屬性,您可以修改這些屬性來變更您在報表中檢視時 Tablix 資料區顯示的方式。Describes properties for a tablix data region that you can modify to change the way a tablix data region appears when you view it in a report.

控制資料列和資料行標題 (報表產生器及 SSRS)Controlling Row and Column Headings (Report Builder and SSRS)
描述資料表、矩陣或清單資料區以水平或垂直方式跨越多個頁面時,如何控制資料列和資料行標題。Describes how to control row and column headings when a table, matrix, or list data region cans span multiple pages horizontally or vertically.

建立遞迴階層群組 (報表產生器及 SSRS)Creating Recursive Hierarchy Groups (Report Builder and SSRS)
描述如何顯示父系和子系之關聯性由資料集中之欄位表示的遞迴資料。Describes how to display recursive data where the relationship between parent and child is represented by fields in the dataset.

了解群組 (報表產生器及 SSRS)Understanding Groups (Report Builder and SSRS)
說明群組的定義和使用時機,並描述可用於不同 Tablix 資料區的群組。Explains what groups are and when you use them and describes the groups available for the different tablix data regions.

請參閱<See Also

加入資料集篩選、資料區篩選和群組篩選 (報表產生器及 SSRS) Add Dataset Filters, Data Region Filters, and Group Filters (Report Builder and SSRS)
巢狀的資料區 (報表產生器及 SSRS ) Nested Data Regions (Report Builder and SSRS)
將多個資料區域連結至相同的資料集 (報表產生器及 SSRS ) Linking Multiple Data Regions to the Same Dataset (Report Builder and SSRS)
運算式 (報表產生器及 SSRS ) Expressions (Report Builder and SSRS)
篩選、 群組和排序資料 (報表產生器及 SSRS ) Filter, Group, and Sort Data (Report Builder and SSRS)
報表參數 (報表產生器和報表設計工具 ) Report Parameters (Report Builder and Report Designer)
圖表 (報表產生器及 SSRS ) Charts (Report Builder and SSRS)
量測計 (報表產生器及 SSRS )Gauges (Report Builder and SSRS)