Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Overview of this book

Table of Contents (20 chapters)
JDBC 4.0 and Oracle JDeveloper for J2EE Development
Credits
About the Author
About the Reviewer
Preface

Creating an Excel Spreadsheet


Create a catalog-excel.jsp in the JasperReports project in JDeveloper for creating a Excel spreadsheet. If an Excel report is required, use a JRXlsExporter object to export the JasperReports document to an Excel spreadsheet. Specify an OutputStream to output the Excel spreadsheet. Specify a ByteArrayOutputStream for the output from the JRXlsExporter object:

OutputStream ouputStream=new FileOutputStream
(new File("c:/JasperReports/catalog.xls"));
ByteArrayOutputStream byteArrayOutputStream = new
ByteArrayOutputStream();

Create a JRXlsExporter object and set the JasperPrint object from which the report is to be generated and the OutputStream to output the report.

JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, print);
exporterXLS.setParameter
(JRXlsExporterParameter.OUTPUT_STREAM,byteArrayOutputStream);

Export the JasperReport document using the exportReport() method:

exporterXLS.exportReport();

Output...