All table based output targets (HTML, Execl, Layouted CSV) have some layout restrictions. These layout restrictions also apply to the PlainText output target:
In Pentaho Reporting Classic, all Report-Elements are positioned somewhere on a canvas. Whenever an band is being printed, the layouting system jumps in an computes the final layout for the band and all child elements. After the layouting is complete, each element has some valid 'bounds', which describe where the painter would have to place the element on the canvas.
The table-generator's work starts after all elements have a valid layout. For each visible element in the band, the layouter takes the bounds and generates a column or row break for each edge position. All bands of the report are added to a single table. Therefore the table's column will be based on all generated column breaks of all bands.
Pentaho Reporting Classic has two table-export modes. In the 'simple' export mode, the table-generator ignores the right and bottom edge of the child elements (but not for the root-level band). If a 'complex' layout is requested, all boundary informations are taken into account.
Theory is dry, lets take a look at some numbers:
Lets assume we have a root-level band with a width of 500 point and a height of 200 points. The band has two childs, a label and a text-field. I'll specify the bounds as absolute positions, (X1,Y1) denotes the upper-left corner, and (X2,Y2) denotes the lower right corner.
The bounds of all elements involved are:
Let's follow the table-generator's steps. We assume that the complex layouting is used.
(empty) |
(empty) |
Label |
A column break for X2 gets inserted at position 300. The table now contains 3 columns.
(empty) |
Label |
(empty) |
The Label's Y1 does not cause a row-break, as the band already caused one at this position. A row break for Y2 gets inserted at position 100. The table now consists of two rows.
(empty) |
Label |
(empty) |
(empty) |
(empty) |
(empty) |
(empty) |
Label |
Label |
(empty) |
(empty) |
Text Field |
(empty) |
(empty) |
If the table-generator uses the simple algorithm, the resulting table gets simplified in a second step. The column breaks at position 250 and 300 have been caused by a right edge of an report element. These breaks now get removed, so that the resulting table looks like this:
(empty) |
Label |
(empty) |
Text Field |
Now it should be clear, that the table-generator works best, if all elements are properly aligned. All elements that should go into one row or column have to start at the same X and y positions. If the strict layouting mode is used, they also must end at the same position. Elements that should go into neighbouring cells must share a common edge. And finally: Elements that do not start at position Zero will cause an empty column or row.
In the next post, I'll cover how Pentaho Reporting Classic computes cell backgrounds and borders.