Jasperreport"

From Documentation
Line 34: Line 34:
 
report.setType("pdf");
 
report.setType("pdf");
 
</zscript>
 
</zscript>
 +
</source>
 +
 +
 +
 +
== Provide Export Parameters ==
 +
The Jasperreport component API provides a way to specify export parameters. To do so, you should put a Map containing export parameters within the parameters Map, with key <tt>"exportParameter"</tt>. For example:
 +
 +
<source lang="java">
 +
Map parameters = new HashMap();
 +
Map exportParams = new HashMap();
 +
exportParams.put("net.sf.jasperreports.export.mypropertyname", true);
 +
parameters.put("exportParameter", exportParams);
 +
report.setParameters(parameters); // report is the Jasperreport component
 +
</source>
 +
 +
=== One-Page-Per-Sheet Property ===
 +
In Jasperreport engine, this property is default to be false. However, the default behavior is turned on in the Jasperreport component, in which case when the report is exported as Excel format there will be one sheet generated for each page. To override this setting, set it as an export parameter as the following:
 +
 +
<source lang="java">
 +
Map parameters = new HashMap();
 +
Map exportParams = new HashMap();
 +
exportParams.put(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET.toString(), false);
 +
parameters.put("exportParameter", exportParams);
 +
report.setParameters(parameters); // report is the Jasperreport component
 
</source>
 
</source>
  

Revision as of 08:04, 14 February 2011

Jasperreport

Employment/Purpose

The JasperReport component. It is used to generate a Jasper report into an inline frame


Example

ZKComRef Jasperreport Examples.PNG

	<jasperreport id="report" height="360px" />
	
	<zscript>
		import org.zkoss.zkdemo.userguide.CustomDataSource;
		
			//Preparing parameters
			Map parameters = new HashMap();
			parameters.put("ReportTitle", "Address Report");
			parameters.put("DataFile", "CustomDataSource from java");
			
			report.setSrc("/userguide/data/jasperreport.jasper");
			report.setParameters(parameters);
			report.setDatasource(new CustomDataSource());
			report.setType("pdf");
	</zscript>


Provide Export Parameters

The Jasperreport component API provides a way to specify export parameters. To do so, you should put a Map containing export parameters within the parameters Map, with key "exportParameter". For example:

	Map parameters = new HashMap();
	Map exportParams = new HashMap();
	exportParams.put("net.sf.jasperreports.export.mypropertyname", true);
	parameters.put("exportParameter", exportParams);
	report.setParameters(parameters); // report is the Jasperreport component

One-Page-Per-Sheet Property

In Jasperreport engine, this property is default to be false. However, the default behavior is turned on in the Jasperreport component, in which case when the report is exported as Excel format there will be one sheet generated for each page. To override this setting, set it as an export parameter as the following:

	Map parameters = new HashMap();
	Map exportParams = new HashMap();
	exportParams.put(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET.toString(), false);
	parameters.put("exportParameter", exportParams);
	report.setParameters(parameters); // report is the Jasperreport component

Supported Events

Name
Event Type
None None

Supported Children

*NONE

Use Cases

Version Description Example Location
5.0.2 How to use Dynamic Jasper Reports http://www.zkoss.org/forum/listComment/10873

Version History

Last Update : 2011/02/14


Version Date Content
5.0.1 March 2010 Support Hibernate and SQL connections



Last Update : 2011/02/14

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.