Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

11.07 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.

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, then 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-8. 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 month of the year, then 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 shown done via the style options in the Format Cross-Tab expert. That expert is shown next.