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 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.
Set the formatting properties by right-clicking on the cross-tab object and selecting Format. 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 cross-tab. This is where there are no other fields that could be selected by mistake.
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.
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 object and select Cross-Tab Expert.
Figure 13-6. Selecting the Cross-Tab Expert menu item.
Click on the Style tab of the Cross-Tab Expert (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. The Style tab makes formatting the cross-tab object easy.
Click on the Customize Style tab to make granular changes to the cross-tab’s style. If you made any custom formatting changes previously, you are 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 13-7. 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. 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 13-2.
Table 13-2. Style formatting properties for cross-tab group options.
Style Property | Description |
---|---|
Suppress Subtotal | 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 Label | Suppresses the label for a suppressed subtotal field. |
Alias for Formula | Changes the name that you use to reference the group in the conditional formatting formulas. |
Background Color | 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 13-3.
Table 13-3. Grid options for the cross-tab object.
Grid Option | Description |
---|---|
Show Cell Margins | 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 Labels | 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 Labels | When there are too many columns to fit on a single page, they will span across to the next page. Turning this option on causes the row labels to be printed on the additional pages. |
Keep Columns Together | 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 Top | Forces row totals to be at the top-most row and column totals will be left-most column. Otherwise they appear at the bottom and to the right. |
Suppress Empty Rows/Columns | Don’t print rows/columns with no data. |
Suppress Row/Column Grand Totals | 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 13-8. 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 un-checking both Draw options. If you don’t want any grid lines to be shown then uncheck the Show Grid Lines option.
Figure 13-8. The Format Grid Lines dialog box.
One important point to be aware of when highlighting individual summary fields is that you can’t modify them using the Cross-Tab Expert dialog box. This dialog box applies changes to the cross-tab report as a whole. It doesn’t affect the data within the report. To do this, you have to move your cursor on top of the summary field and right-click. This opens the pop-up menu where you can select Format Field. See Figure 13-9 for an example.