easyexcel与vue配合下载excel
// 这里 指定文件
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();) {
// try (ExcelWriter excelWriter = EasyExcel.write(fileName).build()) {
if (hasXL) {
WriteSheet writeSheet2 = EasyExcel.writerSheet(2, "小料费用差异对比").head(DepreciationEquipXLDto.class).build();
// 获取小料费用差异
List<DepreciationEquipXLDto> data2 = assetDepreciationSingleDetailService.getDepreciationEquXLCompare(entityList);
excelWriter.write(data2, writeSheet2);
}
if (hasJL) {
WriteSheet writeSheet = EasyExcel.writerSheet(0, "其他费用差异对比").head(DepreciationOtherDto.class).build();
// 获取其他费用差异
List<DepreciationOtherDto> data = assetDepreciationSingleDetailService.getDepreciationOtherCompare(entityList);
excelWriter.write(data, writeSheet);
WriteSheet writeSheet1 = EasyExcel.writerSheet(1, "胶料费用差异对比").head(DepreciationEquipJLDto.class).build();
// 获取胶料费用差异
List<DepreciationEquipJLDto> data1 = assetDepreciationSingleDetailService.getDepreciationEquJLCompare(entityList);
excelWriter.write(data1, writeSheet1);
}
WriteSheet writeSheet3 = EasyExcel.writerSheet(3, "总费用差异对比").head(DepreciationTotalDto.class).build();
// 获取总费用差异
List<DepreciationTotalDto> data3 = assetDepreciationSingleDetailService.getDepreciationTotalCompare(entityList);
excelWriter.write(data3, writeSheet3);
// 获取具体的折旧明细
WriteSheet writeSheet4 = EasyExcel.writerSheet(4, "折旧明细").head(DepreciationSingleDetailDto.class).build();
// 获取具体的折旧明细
List<DepreciationSingleDetailDto> data4 = assetDepreciationSingleDetailService.getDepreciationSingleDetail(entityList);
excelWriter.write(data4, writeSheet4);
} catch (IOException e) {
throw new RuntimeException(e);
}