EasyPOI根据模板导出多Sheet页Excel java

 @GetMapping(value = "downloadtest")
    public void downloadtest(HttpServletRequest request, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> reportMoneyExportList = new ArrayList<>();
        Map<String, Object> moneyExport = new HashMap<>();
        moneyExport.put("seq", "1");
        moneyExport.put("projectId", "2");
        moneyExport.put("name", 3);

        Map<String, Object> moneyExport1 = new HashMap<>();
        moneyExport1.put("seq", "112122");
        moneyExport1.put("projectId", "22122");
        moneyExport1.put("name", 333);
        reportMoneyExportList.add(moneyExport);
        reportMoneyExportList.add(moneyExport1);
       
        TemplateExportParams params = new TemplateExportParams("D:\\drgTest.xls", true);
        params.setStyle(ExcelStyleType.BORDER.getClazz());
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("dataList", reportMoneyExportList);
        map.put("dataList2", reportMoneyExportList);
        Workbook book = ExcelExportUtil.exportExcel(params, map);
        File savefile = new File("D:/excel/");
        if (!savefile.exists()) {
            savefile.mkdirs();
        }
        FileOutputStream fos = new FileOutputStream("D:/excel/test.xls");
        book.write(fos);
        fos.close();
    }

Sheet1

 

 

 Sheet2

 

posted @ 2022-07-06 10:09  .NET_海  阅读(1065)  评论(0)    收藏  举报