在实际运用中,数据导入,会遇到模板下载,但是下载后,Excel文件损坏无法打开
模板位置
下载代码
@PostMapping("/downloadExcel")
public void downloadExcel(HttpServletResponse response) {
try {
ClassPathResource resource = new ClassPathResource("excel" + File.separator + "限制出卡模板.xlsx");
// 获取文件
File file = resource.getFile();
logger.info("文件名称:{}", file.getName());
String fileName = "payCardLimit" + DateUtil.getTimeFormat(new Date()) + ".xlsx"