I am trying to save the Jasperreport into an excel file. But while we generate the excel file only the webpage content is saved to the excel file. The Jasper report content is not saved to the excel file.
public void generateXLSOutput(JasperPrint jasperPrint, HttpServletResponse resp) throws IOException, JRException {
String reportfilename = "SampleExcelReport" + ".xls";
@SuppressWarnings("deprecation")
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, resp.getOutputStream());
resp.setHeader("Content-Disposition", "inline;filename=" + reportfilename);
resp.setContentType("application/vnd.ms-excel");
exporterXLS.exportReport();
}