Controller
@GetMapping("/recallMotorcadeExportData")
@ApiOperation("车队模式_回溯_导出表格")
public void recallMotorcadeResultExportData(HttpServletResponse response, @RequestParam Map<String, Object> paramMap) {
recallMotorcadeService.recallMotorcadeResultExportData(response, paramMap);
}
Service
void recallMotorcadeResultExportData(HttpServletResponse response, Map<String, Object> paramMap);
ServiceImpl
@Override
public void recallMotorcadeResultExportData(HttpServletResponse response, Map<String, Object> param) {
int count = cdBacktrackFactService.findRecallMotorListCountByAll(param);
param.put("page", "1");
param.put("pageSize", count);
List<Map<String, Object>> recallMotorcadeResultList = cdBacktrackFactService.findRecallMotorListByAll(param);
//获取回溯车队模式模板,并传入数据
String templatePath = Constant.templateRootPath + "RecallMotorcareMouldExport.xlsx";
String fileName = "车队方案回溯报告";
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(fileName);
TemplateExportParams template = new TemplateExportParams(templatePath);
Map<String, Object> map = new HashMap<>();
map.put("mapList", recallMotorcadeResultList);
map.put("name","车队方案回溯报告");
Workbook tempWorkbook = ExcelExportUtil.exportExcel(template, map);
Map<CellStyle, CellStyle> styleMap = new HashMap<>();
ExcelUtil.copySheet(workbook, tempWorkbook.getSheetAt(0), sheet, 0, 0, true, styleMap);
ExcelUtils.exportExcel(fileName, response, workbook);
}