Java Reference
In-Depth Information
Crosstabs
Crosstab (cross-tabulation) reports are reports containing tables that tabulate data
across rows and columns. This feature was introduced in JasperReports 1.1. The
following example illustrates the use of crosstab in a report. The JRXML template
the use of crosstab in a report. The JRXML template
will generate a report displaying a table containing the number of aircraft in each city
in the state of New York. The last column of the table will display the total number
of aircraft for all models in the table in each city. The last row will display the total
number of aircraft of each model in the table. To avoid having an unmanageable
number of columns in the table, we will limit the report to aircraft models that start
with the letter C .
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//
EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="CrossTabDemoReport" leftMargin="5"
rightMargin="5">
<queryString>
<![CDATA[select
a.city, am.model, a.tail_num
from aircraft a, aircraft_models am
where a.state='NY' and am.model like 'C%'
and a.aircraft_model_code = am.aircraft_model_code
order by city, model]]>
</queryString>
<field name="tail_num" class="java.lang.String"/>
<field name="model" class="java.lang.String"/>
<field name="city" class="java.lang.String"/>
<summary>
<band height="60">
<crosstab>
<reportElement width="782" y="0" x="0" height="60"/>
<rowGroup name="cityGroup" width="100" totalPosition="End">
<bucket>
<bucketExpression class="java.lang.String">
<![CDATA[$F{city}]]>
</bucketExpression>
</bucket>
<crosstabRowHeader>
<cellContents>
<box border="Thin" borderColor="black"/>
<textField>
<reportElement width="100" y="0" x="0" height="20"/>
 
Search WWH ::




Custom Search