9
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode(excelName, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
LongestMatchColumnWidthStyleStrategy longestMatchColumnWidthStyleStrategy = new LongestMatchColumnWidthStyleStrategy();
RowWriteHandlerImpl rowWriteHandler = new RowWriteHandlerImpl(clazz);
EasyExcel.write(response.getOutputStream(), clazz)
.registerWriteHandler(longestMatchColumnWidthStyleStrategy)
.registerWriteHandler(rowWriteHandler)
.sheet(sheetName).doWrite(data);
异常提示
建议描述 本地环境没有问题,发布到线上后存在这个问题 打开文件时提示:发现“xxxx”中部分内容有问题。是否尝试让我们尽量尝试恢复?如果您信任此工作薄的源,请点击“是”