You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Apache POI生成的Excel打开时提示内容异常问题求助

Apache POI生成XLSX文件服务器端打开报错求助

我使用Apache POI 3.17、4.1.0/4.1.1/4.1.2及5.2.5版本生成XLSX文件,本地运行代码完全正常,但部署到服务器后,打开文件时会弹出提示:

We found a problem with some content in abc.xlsx. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes

即使仅保留创建工作表的极简代码(如下),问题仍复现,恳请协助解决该异常。

复现代码

String excelPath = "C:\Users\aa.bb\Desktop\Test.xlsx";

XSSFWorkbook workbook = new XSSFWorkbook();
workbook.createSheet("Report");

ByteArrayOutputStream b_Array_Out = new ByteArrayOutputStream();
workbook.write(b_Array_Out);
byte[] b_FileByte = b_Array_Out.toByteArray();

File batchFile = new File(excelPath);
FileOutputStream fos = new FileOutputStream(batchFile);
fos.write(b_FileByte);
fos.close();

相关截图说明

  • 打开Excel时的错误提示弹窗
  • 生成Excel所依赖的JAR包列表

内容的提问来源于stack exchange,提问作者Mani Gupta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 07:52:15