try {
//构建map集合
List<Map<String,Object>> mapList = new ArrayList<Map<String,Object>>();
Map<String,Object> map1 = new HashMap<String,Object>();
List<InvVoucherIncModel> modelList = getVoucherList(invVoucherIncModel);
map1.put("title",new ExportParams("测试表1","测试表1", ExcelType.XSSF));
map1.put("entity",InvVoucherIncModel.class);
map1.put("data",modelList);
InvVoucherCheckModel invVoucherCheckModel = new InvVoucherCheckModel();
invVoucherCheckModel.setPeriod(invVoucherIncModel.getPeriod());
List<InvVoucherCheckModel> checkModelList = getInvCheckList(invVoucherCheckModel);
Map<String,Object> map2 = new HashMap<String,Object>();
map2.put("title",new ExportParams("测试表2","测试表2",ExcelType.XSSF));
map2.put("entity",InvVoucherCheckModel.class);
map2.put("data",checkModelList);
mapList.add(map1);
mapList.add(map2);
//调用ExcelExportUtil.exportExcel方法生成workbook
Workbook wb = ExcelExportUtil.exportExcel(mapList,ExcelType.XSSF);
FileOutputStream fileOutputStream = null;
String fileId = String.valueOf(System.currentTimeMillis());
String savePath = file.getPath()+File.separator + fileId + ".xlsx";
outExcel = savePath;
fileOutputStream = new FileOutputStream(outExcel);
wb.write(fileOutputStream);
fileOutputStream.close();
}catch (Exception e){
e.printStackTrace();
}
jeecgBoot导出多sheetExcel表
最新推荐文章于 2023-02-18 11:59:51 发布