easyexcel多sheet导出(唯一能用)

时间:2024-10-10 15:00:51

1,response流header, contentType等设置跟单sheet一样

2,上代码

@Data

public class SheetModel<T> {

        private String sheetName;

        private Class<T> clazz;

        private List<T> data;

}

ExcelWriter writer = EasyExcel.write(resp.getOutputStream()).build();
for (SheetModel model: sheetList) {
    WriteSheet sheet =     EasyExcel.writerSheet(model.getSheetName()).head(model.getClazz()).build();
    writer.write(model.getData(), sheet);
}
writer.finish();