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();