Theme:
Description & Source Code

A wrapper component for JasperReport. Depending on your browser, clicking the "Get Report" button would either embed a report in the browser or a native dialog would be invoked to prompt you to save the file.
This demo shows following file type reports :

  • PDF
  • HTML
  • Word (RTF)
  • Excel
  • Excel (JXL)
  • CSV
  • OpenOffice

This feature requires ZK PE or EE.
<zk>
	Choose a File Type : <listbox id="format" mold="select" >
		<listitem label="PDF" value="pdf" selected="true" />
		<listitem label="HTML" value="html" />
		<listitem label="Word (RTF)" value="rtf" />
		<listitem label="Excel" value="xls" />
		<listitem label="Excel (JXL)" value="jxl" />
		<listitem label="CSV" value="csv" />
		<listitem label="OpenOffice (ODT)" value="odt" unless="false" />
	</listbox>
	<button label="Get Report" onClick='showReport()' />
	<jasperreport id="report" height="360px" />
	<zscript><![CDATA[
		import demo.reporting.jasperreport.CustomDataSource;
		
		void showReport() {
			//Preparing parameters
			Map parameters = new HashMap();
			parameters.put("ReportTitle", "Address Report");
			parameters.put("DataFile", "CustomDataSource from java");
			
			report.setSrc("/widgets/reporting/jasperreport/jasperreport.jasper");
			report.setParameters(parameters);
			report.setDatasource(new CustomDataSource());
			report.setType((String) format.getSelectedItem().getValue());
		}
	]]></zscript>
</zk>