fileExt = "xls";
JasperReport report = JasperCompileManager.compileReport(reportsDirectoryPath + reportFileName + ".jrxml");
JasperPrint print = JasperFillManager.fillReport(report, params, conn);
JRXlsExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, out);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
response.setHeader("Content-disposition", "inline; filename=\"" + outputFileName + "." + fileExt + "\"");
response.setHeader("Cache-Control", "no-cache");
response.setContentType(contentType);
exporter.exportReport();
break;
}
out.flush();
out.close();