else if(reportType.equalsIgnoreCase("xlsx")){
JasperPrint jasperPrint = JasperFillManager.fillReport (reportStream, parameters, ds);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition","attachment; filename=\""+ "Accounts.xlsx" + "\"");
JRXlsxExporter exporterXls = new JRXlsxExporter();
exporterXls.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporterXls.setParameter(JRExporterParameter.OUTPUT_STREAM, outStream);
exporterXls.exportReport();
}
else{
JasperPrint jasperPrint = JasperFillManager.fillReport (reportStream, parameters, ds);
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename=\""+ "Accounts.xls" + "\"");
JRXlsExporter exporterXls = new JRXlsExporter ();
exporterXls.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporterXls.setParameter(JRExporterParameter.OUTPUT_STREAM, outStream);
exporterXls.exportReport();
}
outStream.flush();
outStream.close();
}