Java Reference
In-Depth Information
As we can see in the above JRXML template, the number of columns and the
column width are specified by the columnCount and columnWidth attributes of the
<jasperReport> root element.
The column width defaults to 555 , which is also the default
width of a report page, excluding its margins. If we want
to create a report with multiple columns, we must specify a
smaller columnWidth attribute than the default; otherwise,
our JRXML template will fail to compile.
As can be seen in the example above, we can define a column header to be displayed
at the top of every column. This can be accomplished by the <columnHeader>
JRXML element. We can also choose to display a footer at the bottom of every
column by adding a <columnFooter> element to our JRXML template (not shown
in the example). Just like all the other JRXML templates defining report sections,
<columnHeader> and <columnFooter> contain a single <band> element as their
only child element. The <band> element can contain report fields, static text, images,
graphs, or anything else we can display on any of the other report sections.
The following servlet will generate a PDF report from the Jasper file generated from
the above JRXML template and direct it to the browser:
package net.ensode.jasperbook;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.jasperreports.engine.JasperRunManager;
Search WWH ::

Custom Search