The "green bar" effect is a document is the alternating of one background color (usually white) with another background color (originally light green) on each printed line of a document in order to make it easier to read across each line of text. The term comes from the days of impact printers with continuous feed paper that was pre-printed with just such a scheme of alternating colors, and it remains a popular method of making long lists, particularly grids, easy to read. Here is an example:
The method of formatting SQL Server Reporting Services tables with a "green bar" effect is not difficult. Formatting a matrix is only a little more difficult.
Formatting a Table
- In design mode, highlight all the text boxes in the (Details) section. Use a click-and-drag method to select them all in one step or hold down the Ctrl key and click each one in turn.
- On the Properties pane click the down-arrow for the value of the BackgroundColor property, and then click Expression...
- Enter the following expression. If you want colors other than white and light green, substitute your own color choices.
=IIf(RowNumber(Nothing) mod 2 = 0, "LightGreen", "White")
Formatting a Matrix
- Create your matrix, and then right-click on the left-most column and select Insert Column > Inside Group - Left.
- On the bottom-left text box of the matrix, which was just created when you added the new column, right-click and select Text Box Properties...
- Change the Name property to RowNumber.
- Enter the following expression as the Value property:
=RunningValue(Min(1), Sum, Nothing)
- Click OK to confirm the new settings for the text box.
- If you do not want the running count of rows to appear in your final matrix, click on the tablix column marker to select the entire column. Then use the Properties pane to change the Hidden property to True.
- Click on the text box that will show the aggregate data for your matrix (in an Excel PivotTable this would be called the "data region" cell).
- On the Properties pane click the drown-arrow for the value of the BackgroundColor property, and then click Expression...
- Enter the following expression.
=IIf(ReportItems!RowNumber.Value mod 2 = 0, "LightGreen", "White")