Report columns, by default, have no space between them (in the preceding report, the
columns are wider than the displayed tail number; there is a lot of whitespace inside
the columns). We can change this default behavior by using the columnSpacing
attribute of the root <jasperReport> element of the JRXML template.
By default, report columns are filled vertically, that is, the first column is filled to
completion first, then the second, then the third, and so on. If we want to fill the
columns by row, that is, fill the first row of every column first, then the second,
and so on, we can achieve this by setting the printOrder attribute of the root
<jasperReport> element to Horizontal .
Column footers, by default, are printed at the bottom of the page. If a report column
does not have enough data to fill a page, there will be some blank space between the
end of the column and the column footer. If we want the column footer to be printed
right after the end of the column, we can do it by setting the isFloatColumnFooter
attribute of the <jasperReport> element to true .
Grouping Report Data
JasperReports allows us to group report data in a logical manner. For example, if
we were creating a report about cars, we could group the data by car make and/or
model. Similarly, if we were creating a report about sales figures, we could group the
report data by geographical area.
The FlightStats database we used for the examples in Chapter 4 contains the country,
state, and city where an aircraft is registered. Let us create a report displaying
aircraft data registered in any state starting with the letter 'A' in the United States.
We will group the report data by state abbreviation. The JRXML template for the
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
<![CDATA[select a.tail_num, a.aircraft_serial, am.model, a.state
from aircraft a, aircraft_models am
where a.aircraft_model_code = am.aircraft_model_code
and a.country = 'US'
and state like 'A%'
order by state, model]]>