Meny
Index
  • Cross-tab reports
Cross-tab reports
This kind of report has a tabular structure, which means that it consists of rows and columns. At design time it is not known how many lines and columns the output table will have. This is why a report grows not only downwards (as in the types of report previously described) but also sideways. A typical example of a cross-tab report is shown below.
 
Let's look at the elements in the table:
 
 
In the illustration we see a table with two lines (rows) and four columns, where “a” and “b” are line titles, “1”, “2”, “3” and “4” are column titles, and “a1”..”a4” and “b1”..”b4” are cells. To construct a report like this we need just one set of data (from a query or a table) which has three fields and contains the following values:
 
a        1        a1
a        2        a2
a        3        a3
a        4        a4
b        1        b1
b        2        b2
b        3        b3
b        4        b4
 
You can see that the first field contains a line letter, the second a column number and the third the contents of the cell at the intersection of the specified line and column. When outputting the report FastReport creates a table in memory and fills it with data. So the table expands dynamically, creating lines and columns where they do not already exist.
 
Titles can occur at more than one level, as illustrated here:
 
 
In this example the number, or index, of the column is composite, i.e. it consists of two values. This report is generated from the following data:
 
a        10        1        a10.1
a        10        2        a10.2
a        20        1        a20.1
a        20        2        a20.2
b        10        1        b10.1
b        10        2        b10.2
b        20        1        b20.1
b        20        2        b20.2
 
Here the first field contains the line index, as before, the second and third fields contain column indexes and the last field contains the cell value. Look at how FastReport constructs the memory table when handling cross-tab data with complex titles:
 
 
When outputting the report from this memory table FastReport joins those title cells which have the same value and are located at the same level.
 
Here is a more complex cross-tab report, incorporating intermediate and grand totals:
 
 
This report is derived from the same data as before. The values in the cells highlighted in the new color are automatically calculated and are not present in the original data set.
 
 
Onlinehjälpen skapades med Dr.Explain