Sophie

Sophie

distrib > Fedora > 17 > i386 > by-pkgid > cf79c2d0ed7fa2678c515072ee6f31e4 > files > 45

jasperreports-manual-4.0.2-4.fc17.noarch.rpm

<html xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://jasperreports.sourceforge.net/jasperreports">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JasperReports 4.0.2 - Horizontal Sample</title>
<style type="text/css">
.title {
	font-family: Arial, Verdana, Helvetica, sans-serif;
	font-size: 28px;
	font-weight: normal;
}

.toc {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.name {
	font-family: Courier New, Courier, serif;
	font-size: 16px;
	font-weight: bold;
}

.label {
	font-family: Arial, Verdana, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
	font-style: italic;
}

.description {
	font-family: Arial, Verdana, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: normal;
}

.value {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.element {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.attribute {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: bold;
}

.code {
	font-family: Courier New, Courier, serif;
	font-size: 12px;
	font-weight: normal;
}

.copy {
	font-decoration: none;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 8pt;
	font-style: normal;
	color: #000000;
}

.subtitle {
	font-family: inherit;
	font-size: inherit;
	font-style: inherit;
	font-weight: bold;
	text-decoration: none;
	color: inherit;
}

</style>
</head>
<body bgcolor="#FFFFFF">
<a name="top"></a>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td colspan="2" align="right"><span class="element"><a href="../../sample.reference.html">Sample Reference</a> - <a href="../../schema.reference.html">Schema Reference</a> - <a href="../../config.reference.html">Configuration Reference</a> - <a href="http://jasperreports.sourceforge.net/api/index.html">API (Javadoc)</a></span>
<br>
</td>
</tr>
<tr>
<td colspan="2">
<hr size="1">
</td>
</tr>
<tr valign="middle">
<td nowrap="true"><span class="title">JasperReports - Horizontal Sample (version 4.0.2)</span></td><td align="right"><img src="../../resources/jasperreports.png" border="0"></td>
</tr>
<tr>
<td colspan="2">
<hr size="1">
</td>
</tr>
</table>
<br>
<span class="description"><span class="description">Shows how multi-column report templates could be filled horizontally.</span></span>
<br>
<br>
<span class="element"><a href="http://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%204.0.2/jasperreports-4.0.2-project.zip/download" target="_blank">Download All Sample Source Files</a></span>
<br>
<span class="element"><a href="http://jasperforge.org/scm/viewvc.php/tags/jr-4-0-2/jasperreports/demo/samples/horizontal/?root=jasperreports" target="_blank">Browse Sample Source Files on SVN</a></span>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 20px;">
<br>
</td><td>
<br>
</td>
</tr>
<tr>
<td colspan="2"><span class="label">Main Features in This Sample</span></td>
</tr>
<tr>
<td>
<br>
</td><td><span class="element"><a href="#horizontal">Creating Horizontally-Filled, Multi-Column Reports</a></span></td>
</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td><img src="../../resources/px.gif" border="0" width="20" height="1"></td><td width="80%">
<br>
</td><td width="20%">
<br>
</td>
</tr>
<tr>
<td colspan="6" align="right"><a name="horizontal"></a><a href="#top" class="toc">top</a></td>
</tr>
<tr>
<td colspan="6">
<hr size="1">
</td>
</tr>
<tr valign="top">
<td><img src="../../resources/jr-16x16.png" border="0"></td><td colspan="4"><span class="name">Creating Horizontally-Filled, Multi-Column Reports</span></td><td align="right"><span class="copy">Documented by 
	<a href="mailto:shertage@users.sourceforge.net" class="copy">Sanda Zaharia</a></span></td>
</tr>
<tr>
<td colspan="6">
<br>
</td>
</tr>
<tr valign="top">
<td>
<br>
</td><td nowrap="true"><span class="label">Description / Goal</span></td><td>
<br>
</td><td colspan="3"><span class="description">
How to create multi-column, horizontally filled reports.
    </span></td>
</tr>
<tr valign="top">
<td>
<br>
</td><td colspan="1"><span class="label">Since</span></td><td>
<br>
</td><td colspan="3"><span class="description">0.1.0</span></td>
</tr>
<tr>
<td colspan="6">
<br>
</td>
</tr>
<tr>
<td>
<br>
</td><td colspan="5"><span class="description">
    <b>Filling Report Templates</b>
    
<br>
    
<br>
The report-filling process manipulates sets of data to produce high-quality documents. 
It represents a very important piece of JasperReports library functionality, because it 
completes a precompiled report template with its meaningful data. The result is a final document 
ready to be viewed, printed, or exported to other formats. 
This is the main purpose of any reporting tool. 
<br>
The following things should be supplied to the report-filling process as input: 
<ul>

<li>A compiled report template</li>

<li>Report parameters</li>

<li>A data source</li>

</ul>
The <span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperFillManager.html" target="_blank">JasperFillManager</a></span> class is usually used for 
filling a report template with data. This class has various methods that fill report 
templates located on disk, come from input streams, or are supplied directly as in-memory 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperReport.html" target="_blank">JasperReport</a></span> objects.
<br>
The report-filling methods in the <span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JasperFillManager.html" target="_blank">JasperFillManager</a></span> class 
always produce an output that corresponds to the type of input received. When 
receiving a file name for the report template, the generated report is also placed in a file 
on disk. When the report template is read from an input stream, the generated report is 
written to an output stream, etc.
<br>
The various utility methods for filling the reports may not be sufficient for a particular 
application. In such cases, manually loading the report template objects before passing them 
to the report-filling routines shoud be considered. A report template can be loaded using the 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/util/JRLoader.html" target="_blank">JRLoader</a></span> utility class. 
This way, one can retrieve report template properties, such as the report name, to construct the name of the 
resulting document and place it at the desired disk location.
<br>
The report-filling manager class covers only the most common scenarios. However, one 
can always customize the report-filling process using the library&rsquo;s basic functionality. 
<br>

<br>

<b>Reporting Data</b>

<br>

<br>
JasperReports can make use of any data that the parent application might have for 
generating reports because it relies on two simple things: the report parameters and the 
report data source.
<ul>

<li>
<b>Report parameters</b> represent single-named values that are passed to the engine at 
report-filling time. The report parameter values are always packed in a <span class="code"><code>java.util.Map</code></span> object, 
having the parameter names as keys.</li>

<li>
<b>Data sources</b> represent a set of tabular data made of virtual rows and columns that the engine uses 
for iteration during the report-filling process. Normally, the engine works with an instance of the 
<span class="element"><a href="http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/util/JRDataSource.html" target="_blank">JRDataSource</a></span> interface, from which it extracts the 
data when filling the report. If no data source can be retrieved using this interface, there is another possibility to
get a data source: the manager class provides a set of report-filling methods that receive a 
<span class="code"><code>java.sql.Connection</code></span> object as a parameter. This way, data can be retrieved by executing a query on a 
database related to this connection parameter. 
More on data sources can be found at <b>Data Source / Query Executer</b> section 
<a href="http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/sample.reference.html#DataSourceQueryExecuter" target="_blank" class="element">here</a>.
</li>

</ul>

<b>Filling order</b>

<br>

<br>
JasperReports templates allow documents to be structured into multiple columns, like a newspaper. 
The <span class="code"><code>column-count</code></span> attribute in the &lt;jasperReport /&gt; root element specifies the number of columns in the document. 
If this number is not specified, a single-column document is considered by default. 
When multiple-column report templates are used, the order used for filling those 
columns is important. 
<br>
There are two possible column filling orders, specified by the <span class="code"><code>printOrder</code></span> attribute in the &lt;jasperReport /&gt; element:
<ul>

<li>
<b>Vertical</b> - the filling process run first from top to bottom and then from left to right; the first column is entirely filled, then the second one, the third, etc.</li>

<li>
<b>Horizontal</b> - the filling process run first from left to right and then from top to bottom; the first row is filled in any column, then the second row, etc.</li>

</ul>
When filling report templates horizontally, dynamic text fields inside the detail section 
do not stretch to their entire text content, because this might cause misalignment on the 
horizontal axis of subsequent detail sections. The detail band actually behaves the same 
as the page and column footers, preserving its declared height when horizontal filling is 
used.
<br>
The reports/HorizontalReport.jrxml template in this sample contains a 3-column report filled horizontally. 
In order to do that, the only needed steps are:
<ul>

<li>set the column count: <span class="code"><code>columnCount="3"</code></span>
</li>

<li>set the print (filling) order: <span class="code"><code>printOrder="Horizontal"</code></span>
</li>

<li>set the column width and column spacing, according them to the available page width and margins: <span class="code"><code>pageWidth="595" pageHeight="842" columnWidth="175" columnSpacing="5" leftMargin="30" rightMargin="30"</code></span>
</li>

</ul>

<b>Running the Sample</b>

<br>

<br>
Running the sample requires the <a href="http://ant.apache.org/" target="_blank" class="element">Apache Ant</a> library. Make sure that <span class="code"><code>ant</code></span> is already installed on your system (version 1.5 or later).
<br>
In a command prompt/terminal window set the current folder to <span class="code"><code>demo/hsqldb</code></span> within the JasperReports source project and run the <span class="code"><code>&gt; ant runServer</code></span> command. 
It will start the HSQLDB server shipped with the JasperReports distribution package. Let this terminal running the HSQLDB server.  
<br>
Open a new command prompt/terminal window and set the current folder to <span class="code"><code>demo/samples/horizontal</code></span> within the JasperReports source project and run the <span class="code"><code>&gt; ant test view</code></span> command.
<br>
It will generate all supported document types containing the sample report in the <span class="code"><code>demo/samples/horizontal/build/reports</code></span> directory. 
<br>
Then the report will open in the JasperReports internal viewer.
    </span></td>
</tr>
<tr>
<td colspan="6">
<br>
</td>
</tr>
</table>
<br>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td>
<hr size="1">
</td>
</tr>
<tr>
<td align="center"><span class="copy">&copy; 2001-2010 Jaspersoft Corporation <a href="http://www.jaspersoft.com" target="_blank" class="copy">www.jaspersoft.com</a></span></td>
</tr>
</table>
</body>
</html>