Cross-tabs within Crystal Reports .NET can be used to display summarized data in rows and columns, similar to a spreadsheet. If you want to create a report with a cross-tab as its main feature, there is a Cross-Tab Expert available that will guide you through the steps to do so.
You can also insert a cross-tab into an existing report, which we will walk through here. You may want to create a copy of the report we have been working with before starting this section. That way you can always return to the original, which we will use a little later for charting. To insert a cross-tab into your report, right-click the report and then select Insert ^ Cross-Tab from the menu, as shown in Figure 3-22.
Speciai Field ► Text Object
Database * Report i Designer ►
Subtotal. Grand Total. Summary.
Undo (Ctrl+ZJ: Resize Object
Cut Copy Paste Delete
Register / Change Address.
OLE Object. Hyperlink.
This makes a box appear over your cursor, which you should position over your report where you want it to appear. Place the cursor over the Group Header #1: Customer.Country - A section, next to the Group #1 Name label. Left-click the mouse, and the dialog shown in Figure 3-23 will open. When working with a cross-tab, there are three basic elements: rows, columns, and summarized fields. To start, you will need to select at least one of each using this dialog.
Figure 3-23
Select Customer.Country for the row and Customer.Region for the column. Select Customer.Last Year's Sales so it is highlighted, and then click the Add Summarized Field button so Sum of Customer.Last Year's Sales appears in the summarized field. Click OK to create this cross-tab.
In the first section under each country, your report now has a summary of the last year's sales by region. In the screenshot shown in Figure 3-24, we have the sales by region for the USA. If you select England in the list to the left of the report, the same cross-tab will appear with values for the regions in England.
By default, Crystal Reports .NET applies some standard formatting to your cross-tab and draws lines and boxes around the columns and rows. With the use of a style sheet, you can apply a predefined style to your cross-tab, as shown in Figure 3-25, or simply change individual attributes to suit.
Cross-tabs have come a long way since the early version of Crystal Reports. Now if the data runs off the page, it is continued on the next page and a margin is used so the data is not cut off, eliminating the old problem of taping multiple report pages back together.
The only down side is that there are still some issues with page numbering. If your cross-tab runs across multiple pages, the page number will not work correctly (for instance, if it is three pages across and three down when printed, only the first and every third page will have a number, and it will be 1. 2. 3). Still, those limitations are minor in comparison to the functionality provided.
Figure 3-24
Was this article helpful?