Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

11.05 Formatting

Formatting the Cross-Tab Grid

As with every report object in Crystal Reports, the cross-tab object has many formatting options to make it look just the way you want. These changes can be categorized according to whether they affect the grid and its layout or whether they affect the individual fields within the grid.

Since the number of rows and columns of the cross-tab is dynamic, you can’t control its final size on the report. But you can control the individual row and column widths. This has a direct effect on the total size of the cross-tab grid when it prints. When you select a field in the cross-tab object and resize it, the entire row and column changes to reflect this change. Changing the width changes the width of the entire column. Changing the height changes the height of the entire row. Thus, a change to one field affects all the fields that are in the same column and row.

To set the standard formatting properties of the overall cross-tab object, right-click on the cross-tab object and select Format Object. Be careful when doing this because if your cursor is positioned above one of the fields in the cross-tab, you will get the format dialog boxes for that field. To set the formatting for the cross-tab object, position your cursor in the top left-hand corner of the object. This is where there are no other fields that could be selected by mistake.



Figure 11-7. Selecting the Format menu item of the cross-tab object.

Both the grid and the fields within the grid can be formatted using the standard formatting properties. Some examples of these properties are suppressing the object, setting the font properties, changing the border, etc. Most of these properties have a formula button so that their value can be the result of a formula that you program.

There are two formatting related functions that can be used with cross-tab cells. As stated earlier, each cell has to display the output of the same formula. However, you can make each cell stand out by using the formulas with the formatting properties. Since each cell is identical, there are two formulas that let you identify what value is being displayed as well as identifying the current row and column values. The CurrentFieldValue() function returns the cell’s current value. Use this to highlight values that fall within or outside of a certain range. The function GridRowColumnValue() returns the value of the row or column that the cell is in. Pass it the name of the group field, either the row’s field name or the column’s field name, and it returns the current value. For example, if the column groups by months of the year, a cell in the third column will return the month name “March”. If you want to refer to the row or column field as a different name, assign it an alias to make it easier to reference it. This is done via the style options in the Format Cross-Tab expert. That expert is shown next.

Formatting the Style Properties

The grid has some unique formatting properties that don’t appear with other objects. These are called the Style properties. Right-click on the cross-tab and select Cross-Tab Expert. The Cross-Tab tab is shown by default and this has already been discussed. Click on the Style tab, the second tab, to choose from a list of more than a dozen predefined styles. As you click on each style, the right window shows a template of how your cross-tab object will be formatted.

Click on the Customize Style tab to make your own changes to the style. If you selected a predefined style in the previous tab, you will be prompted about whether you want to save that style. If you choose Yes, the new style will be reflected on the Customize Style tab. If you choose No, the Customize Style tab will reflect the formatting of the cross-tab object before you opened the Cross-Tab Expert.



Figure 11-8. The CustomizeStyle tab of the Format Cross-Tab expert.

The Customize Style tab has numerous properties that you can use to format the cross-tab grid to look exactly like you want. There is a Rows window and a Columns window and within each window are the names of the grouping fields. Click on the field you want to format to change its properties. The properties and their descriptions are listed in the Group Options frame directly below those windows. Each of these properties only affects the group field that is currently selected. These style properties are listed in Table 11-2.

Table 11-2. Style formatting properties for cross-tab group options.

Style Property Description
Suppress Subtota When you have multiple groups for a row or column, the cross-tab grid shows a subtotal for the top-most groups. This suppresses that subtotal from printing.
Suppress Labe This suppresses all data for that field from appearing in the cross-tab grid.
Alias for Formul This changes the name that you use to reference the group in the conditional formatting formulas.
Background Colo Sets the background color for the cell.

At the bottom of the dialog box is a frame titled Grid Options. The properties listed in this frame apply to the entire cross-tab. These grid options are listed in Table 11-3.

Table 11-3. Grid options for the cross-tab object.

Grid Option Description
Show Cell Margin By default, each group field has a margin surrounding it. Turning this off makes the edge of the group field flush with the grid lines.
Indent Row Label The row labels can be indented so that they are offset from the Total row. This makes it easier to notice the Total row and it makes your report appear more professional. When this is checked, you can specify the indentation in inches.
Repeat Row Label When there are too many columns to fit on a single page, they will span across to the next page. Setting this option on causes the row values to be printed on the additional pages. This option is only available if you have the Keep Columns Together option enabled.
Keep Columns Togethe Select this option (it is selected by default) to force columns that span multiple pages to stay intact. Unselecting this option could cause a column to be split in half.
Row/Column Totals on To Forces totals to be switched from their default position. Row totals will be at the top-most row and column totals will be left-most column.
Suppress Empty Rows/Column Don’t print rows/columns with no data.
Suppress Row/Column Grand Total Don’t print the grand-totals for rows and/or columns.

The Format Grid Lines button is used to set the line styles for the grid. Clicking on this button brings up the Format Grid Lines dialog box shown in Figure 11-9. For each grid line in the cross-tab object, you can set the color, style, and width properties. You can also suppress a line by unchecking both Draw options. If you don’t want any grid lines to be shown then uncheck the Show Grid Lines option.



Figure 11-9. The Format Grid Lines dialog box.