批量导出多sheet页Excel
/**
* 导出多Sheet页excel格式文件
* @param jasperPrintList JasperPrint对象集合
* @param sheetNames sheet页名称集合
* @param destFilePath 导出路径
*/
public static void batchExportExcelFile(List<JasperPrint> jasperPrintList,String[] sheetNames,String destFilePath){
JRXlsExporter xls = new JRXlsExporter();
xls.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));
xls.setExporterOutput(new SimpleOutputStreamExporterOutput(destFilePath));
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
configuration.setOnePagePerSheet(true);//在一个excel中,每个单独的jasper对象放入到一个sheet页中
configuration.setSheetNames(sheetNames);
configuration.setDetectCellType(true);// 检查单元格格式
configuration.setWhitePageBackground(false);//去除白边
xls.setConfiguration(configuration);
try {
xls.exportReport();
} catch (Exception e) {
e.printStackTrace();
}
System.out.p