| | |
| | | .collect(Collectors.groupingBy(CostStatisticsDto::getCompany)); |
| | | try { |
| | | // 新建ExcelWriter |
| | | ExcelWriter excelWriter = |
| | | EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); |
| | | |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); |
| | | for (Map.Entry<String, List<CostStatisticsDto>> companyDataEntry : groupByCompany.entrySet()) { |
| | | String sheetName = companyDataEntry.getKey(); |
| | | List<CostStatisticsDto> dataList = companyDataEntry.getValue(); |
| | | WriteSheet mainSheet = EasyExcel.writerSheet(sheetName).head(CostStatisticsDto.class).build(); |
| | | excelWriter.write(dataList, mainSheet); |
| | | } |
| | | |
| | | |
| | | // 关闭流 |
| | | excelWriter.finish(); |
| | | } catch (IOException e) { |