{
res.addOutput("contentType", "application/pdf");
res.addOutput("fileName", "Report.pdf");
ByteArrayOutputStream buf = new ByteArrayOutputStream();
JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
exporter.exportReport();
outReport.setContent(buf.toByteArray());
}
else if ("csv".equals(format))
{
res.addOutput("contentType", "text/plain");
res.addOutput("fileName", "Report.csv");
ByteArrayOutputStream buf = new ByteArrayOutputStream();
JRExporter exporter = new JasperCSVExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
exporter.setParameter(JRExporterParameter.IGNORE_PAGE_MARGINS, true);
exporter.setParameter(JRExporterParameter.FILTER, noLayoutFilter);
exporter.exportReport();
outReport.setContent(buf.toByteArray());
}
else if ("xml".equals(format))
{
res.addOutput("contentType", "text/xml");
res.addOutput("fileName", "Report.xml");
ByteArrayOutputStream buf = new ByteArrayOutputStream();
JRExporter exporter = new JRXmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
exporter.setParameter(JRExporterParameter.IGNORE_PAGE_MARGINS, true);
exporter.setParameter(JRExporterParameter.FILTER, noLayoutFilter);
exporter.exportReport();
outReport.setContent(buf.toByteArray());
}
else if ("xls".equals(format))
{
res.addOutput("contentType", "application/xls");
res.addOutput("fileName", "Report.xls");
ByteArrayOutputStream buf = new ByteArrayOutputStream();
JRExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, buf);
exporter.setParameter(JRExporterParameter.IGNORE_PAGE_MARGINS, true);
exporter.setParameter(JRExporterParameter.FILTER, noLayoutFilter);
exporter.exportReport();
outReport.setContent(buf.toByteArray());
}
else
{
StringBuffer buf = new StringBuffer();
JRExporter exporter = new JRHtmlExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, buf);
exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");
exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");
exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(true));
exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(page - 1));
exporter.exportReport();
outReport.setContent(buf.toString());
createPageNavigationControls(req, res, page, reportPrint.getPages().size(), reportModel, backModel);
}
}