这里介绍一种通过接口去生成导入数据Excel模板
1、controller
2、serviceImpl
@Override public void downloadOrderTemplate(HttpServletResponse response) { List<WorkOrderVoImportDto> orderVoImports = new ArrayList<>(); try { List<String> sheetNameList = Lists.newArrayList(); Map<String, Object> map = Maps.newHashMap(); Map<String, Object> classMap = Maps.newHashMap(); sheetNameList.add("工单数据导入模板"); map.put("工单数据导入模板", orderVoImports); classMap.put("工单数据导入模板", WorkOrderTemplateDto.class); Workbook workbook = EasyPoiUtils.exportSheetExcel(map, sheetNameList, classMap); EasyPoiUtils.downLoadExcel("工单数据导入模板", response, workbook); } catch (Exception e) { log.error("工单导入模板:{}", e); } }
3、WorkOrderVoImportDto 对象张下面这样
3、WorkOrderTemplateDto模板实体类如下,width自行设置
以上只是记录,作为笔记和学习使用!!
标签:map,sheetNameList,接口,classMap,导入,工单,模板 From: https://www.cnblogs.com/qwg-/p/18023625