Редагувати

Поділитися через


Tutorial: Add a table to the report (Reporting Services)

After you define the dataset, you can design a paginated report. You create a report layout by dragging and dropping report objects from the Toolbox pane to the Design surface.

Items that contain repeated rows of data from underlying datasets are called data regions. After you add a data region, you can add fields. A basic report has only one data region. You can add extras, like a chart, to display more information.

In this tutorial, you:

  • Add a table data region to the report layout.
  • Populate the table with fields from the dataset.
  • Preview your report to validate design and data connections.

Prerequisites

Add a table data region and fields to a report layout

In this section, you add a table data region to your report layout and populate it with fields from your dataset to display organized data.

  1. Open your Sales Order report definition file (.rdl) in Visual Studio.

  2. Select the Toolbox tab in the left pane of the Report Designer. If you don't see the Toolbox tab, select View > Toolbox.

  3. Choose the Table object and drag it to the report design surface. You can also add a table to the report from the design surface. Right-click the design surface and select Insert > Table.

    Screenshot of the Toolbox tab with the Table option selected.

    Report Designer draws a table data region with three columns in the center of the design surface.

  4. In the Report Data pane, expand AdventureWorksDataset to display the fields.

  5. Drag the Date field from the Report Data pane to the first column in the table.

    Important

    When you drop the field into the first column, two things happen.

    • Report Designer displays the field name, known as the field expression, in brackets. For example, in this tutorial, Date displays in the data cell.
    • Report Designer adds a column label to the header row, just above the field expression. By default, the column label is the name of the field. You can select the column label and enter a new value if you want to change it.
  6. Drag the Order field from the Report Data pane to the second column in the table.

  7. Drag the Product field from the Report Data pane to the third column in the table.

  8. Drag the Qty field to the right edge of the third column until you get a vertical cursor and the pointer shows a plus sign [+]. Drop the field to create a fourth column for the Qty field expression.

    Screenshot of the Product field in the table.

  9. Add the LineTotal field in the same way, creating a fifth column. The column label shows as "Line Total". Report Designer automatically creates a friendly name for the column by splitting "LineTotal" into two words.

    Diagram of a table data region populated with the fields: Date, Order, Product, Qty, and Line Total.

Preview your report

While designing, preview your report frequently. By doing so, you validate the design and data connections and you can correct errors and issues as you go.

  1. Select the Preview tab.

    Screenshot of the Preview tab in Report Designer.

    Report Designer runs the report and displays it in the Preview view.

    Diagram of part of the report in the Preview view.

  2. Select File > Save All to save the report.

Next step