//查询下拉分类列表
        List<String> allNameList = new ArrayList();
List<FtbCultivateLabelVo> labelVoList = new ArrayList();

response.setHeader("Content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode("鉴定表下载模版.xlsx", StandardCharsets.UTF_8));
//下载远程模版
InputStream inputStream = EasyExcelUtils.checkExcelFile("http://127.0.0.1/1.xlsx");

//创建workbook 并设置对应单元格下拉列表和值
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheetAt = workbook.getSheetAt(0);
ExcelUtil<Object> util = new ExcelUtil<>(Object.class);
String[] itemCategoryNameList = new String[]{};
if (CollUtil.isNotEmpty(allNameList)) {
itemCategoryNameList = allNameList.toArray(new String[0]);
}
util.setPromptOrValidation(sheetAt, itemCategoryNameList, "", 6, 1000, 2, 2);
String[] lableNameList = new String[]{};
if (CollUtil.isNotEmpty(labelVoList)) {
lableNameList = labelVoList.stream().map(FtbCultivateLabelVo::getName).toArray(String[]::new);
}

util.setPromptOrValidation(sheetAt, lableNameList, "", 1, 1, 1, 1);

//构建默认填充数据 列表
List<V2IdentifyItemsExportVo> list = new ArrayList<>();
V2IdentifyItemsExportVo v2IdentifyItemsExportVo = new V2IdentifyItemsExportVo();
v2IdentifyItemsExportVo.setItemNum("1");
v2IdentifyItemsExportVo.setItemName("鉴定项名称");
if (CollUtil.isNotEmpty(allNameList)) {
v2IdentifyItemsExportVo.setCateName(allNameList.get(0));
} else {
v2IdentifyItemsExportVo.setCateName("");
}
v2IdentifyItemsExportVo.setItemScore("1 - 20");
list.add(v2IdentifyItemsExportVo);

//构建当个默认填充数据
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("tableName", "鉴定表名称");
dataMap.put("date", "2024-01-01");
// 使用临时文件流方式填充模板
File tempFile = null;
FileInputStream fileInputStream = null;
try {
// 创建临时文件 把刚刚修改的excel保存
tempFile = File.createTempFile("鉴定表模板_", ".xlsx");
FileOutputStream fileOut = new FileOutputStream(tempFile);
workbook.write(fileOut);
fileOut.close();

// 关闭原始 workbook
workbook.close();
inputStream.close();

// 重新读取临时文件并填充
fileInputStream = new FileInputStream(tempFile);
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
.withTemplate(fileInputStream)
.build()) {
WriteSheet writeSheet = EasyExcel.writerSheet(0).build();

// 先填充单个数据(Map
excelWriter.fill(dataMap, writeSheet);
// 再填充列表数据(List
excelWriter.fill(list, writeSheet);
}
} finally {
// 关闭流
if (fileInputStream != null) {
fileInputStream.close();
}
// 删除临时文件
if (tempFile != null && tempFile.exists()) {
tempFile.delete();
}
}

模版样式这个样子

example