Report Builder Report Headers


By:
Overview

The Report Header is the top section of a report.  It usually contains the report title, page number, execution date and time, and so on.  This topic will walk through the steps for adding the report header to a report. 

Explanation

To begin select Blank Report from either the Getting Started dialog or the New Report or Dataset dialog.  We discussed these dialogs in the Getting Started section; you can return there if you need the details.  You now have a blank report design surface.  Click Header on the Insert tab of the Report Builder ribbon and select Add Header from the popup menu:

AddHeader

The report design surface shows the blank report header at the top:

BlankHeader

Let's create a report header that includes the following:

  • Run date and time
  • Report Title
  • Page Number
  • Total Pages

To setup the report header, expand the Built-in Fields node in the Report Data area of Report Builder:

ReportData

Follow these steps to fill in the report header:

  • Drag and drop the following items underneath Built-in Fields onto the report header area: Page Number, Total Pages, Execution Time
  • Drag a TextBox from the Insert tab onto the report header area; drop it to the left of the Page Number
  • Drag a TextBox from the Insert tab onto the report header area; drop it between the Page Number and Total Pages; set the value to "of"
  • Drag a TextBox from the Insert tab onto the report header area and drop it in the middle of the report header area; set the value to the report title

After you drag and drop an item onto the report design surface, click on the edges to "select" the item.  Once an item is selected, its properties are displayed in the Properties window, allowing you to change the settings.  You can also click with the left mouse button and move the item around to position it right where you want it.

Click Run on the Home tab to preview the report:

ReportHeader1

When previewing your report, the Run tab is displayed which provides options to zoom in and out, navigate between the pages of the report, refresh, print, export and so on.  The export feature provides a number of options for saving the report in different formats:

Export

Let's change the report header to use an expression for the Page N on N: 

  • Select "Page", Page Number, "of" and Total Pages and delete them (to select multiple items you can click the first item with the left mouse button, then click Ctrl + left mouse button click each additional item)
  • Drag and drop a TextBox from the Insert tab onto the report header area; place it on the left edge
  • Right click the TextBox and select Expression from the menu
  • Add in the following expression using the expression builder:
PageNumberExpression

You can build the expression by typing it in; you can also click an item in the Category list, then double click an item in the Item list to add it to the expression.  The Globals items are in the Built-in Fields category.  The CStr() function is in the Common Functions / Conversion category; it converts its argument to a string.  By default a number is right justified so this will eliminate the leading spaces.  Click OK and click Run on the Home tab to preview the report:

ReportHeader2
Additional Information

Last Update: 6/23/2011




Comments For This Article

















get free sql tips
agree to terms