|
This works with Hibernate 3 but should be ok for you:
ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();
InputStream inputStream;
inputStream = new FileInputStream(reportFile.getPath());
JRXlsExporter xlsExporter = new JRXlsExporter();
JasperPrint jasperPrint =
JasperFillManager.fillReport(
inputStream,
params,
new JRBeanCollectionDataSource(StoreVoucherList)
);
xlsExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
xlsExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, xlsReport);
xlsExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
xlsExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
xlsExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
xlsExporter.exportReport();
OutputStream ouputStream = response.getOutputStream();
ouputStream.write(xlsReport.toByteArray());
ouputStream.flush();
ouputStream.close();
|