poi導出excel異常:Excel 已完成文件級驗證和修復。此工作簿的某些部分可能已被修復或丟棄
導出表格之后,有這個提示,但是檢查代碼發現是因為這個接口設置了return的內容導致的異常;
解決方法:
將接口的返回類型設置為void
,使用response導出數據
response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
response.setContentType("application/ms-excel;charset=UTF-8");
OutputStream out = response.getOutputStream();
wb.write(out);
// out.flush(); //不要有這個,否則會提示 終止了連接
out.close();