String path = "E:\\人员信息表.xlsx";
EasyExcel.write(path, Promotion.class).sheet("sheet1").doWrite(promotionList);
EasyExcel.write(path, GoodsPromotion.class).sheet("sheet2").doWrite(list);
执行两行代码的时候 后面的sheet会覆盖前面你的sheet。
修改:
ExcelWriter excelWriter = EasyExcel.write(path).build(); WriteSheet sheet1 = EasyExcel.writerSheet("sheet1").head(Promotion.class).build(); WriteSheet sheet2 = EasyExcel.writerSheet("sheet2").head(GoodsPromotion.class).build(); excelWriter.write(promotionList, sheet1); excelWriter.write(list, sheet2); excelWriter.finish();
这样就可以了。