Table with composite headers Our previous example contained one value per line, and column headers. Let us examine in practice the table construction with a complex header, which means that it would contain two or more values. To perform this, we would need the "cross.db" table, which is located in the FastReport "DEMOS\CROSS\DATA" folder. The table contains data of the following kind:
Name | Year | Month | Days | Salary
Ann | 1999 | 2 | 3 | 1000
Ben | 2002 | 1 | 5 | 2000
….
As you can see, this table data is similar to the "simplecross.db" table, which we used in the previous example. We have added the "Month" and "Days" fields, which contain month number and the number of working days respectively. One can construct several reports on the basis of this data, for example, salary of all the employees during all years, burst by months. Let us create a new project in Delphi, put the "TTable," "TfrxDBDataSet," and "TfrxReport" components on the form, and set them: Table1: DatabaseName = 'c:\Program Files\FastReport3\Demos\Cross\Data' TableName = 'cross.db' Of course, the DatabaseName property value must correspond to the path to your folder with FastReport! frxDBDataSet1: DataSet = Table1 UserName = 'Cross' In the report designer, we do usual things: connect the data source using the "Report|Data…" window, and then put the "DB cross-table" object to the report list. To set the cross-object, let us start its editor by double-clicking on the object. What kind of a report we are going to get? It must resemble the report from the previous example, but at the same time it must be burst by months. Consequently, the cross-object must be set in the same way, but with adding the "Month" field into the column header: Thus, in the bottom part of the editor the future report structure is displayed: As a result, we would get the following report: Note, that FastReport automatically added a column of the intermediate totals, which are displayed after each year. This option can be set in the cross-object editor: it is enough to select the "Year" column element and disable the "Subtotal" flag: In addition, one can note that there is no intermediate total in the bottommost column element (the same is true in cases, when this element is the only one). Actually, in our example, we do not need intermediate totals for each month. Let us examine another feature, concerning intermediate totals. In our example, it is desirable to display "2000 year total" instead of the "Total" inscription. It is quite easy to be performed. Enter the cross-object editor, select the required object in the bottom part of the editor, and then enter the following text to it: Total for [Value] During construction, the "Value" expression will be replaced by the table inscription value, located above: