gpt4 book ai didi

java - org.apache.poi.poifs.filesystem.OfficeXmlFileException

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:21:30 25 4
gpt4 key购买 nike

我想使用 POI 阅读 Microsoft Word 文档,即 .docx 格式,但出现错误:

The supplied data appears to be in the Office 2007+ XML. POI only supports OLE2 Office documents

如果有人能帮我摆脱这个??

最佳答案

您应该通读 Converting from HSSF to the Common SS Usermodel page帮助您了解需要更改的内容。

不过,作为一般指南,如果您的代码之前是

 HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream("foo.xls"));
HSSFSheet s = wb.getSheetAt(0);
HSSFRow r = s.getRow(0);
System.out.println("Cell A1 is " + r.getCell(0));

它应该变成

 Workbook wb = WorkbookFactory.create(new File("foo.xls")); // Or foo.xlsx
Sheet s = wb.getSheetAt(0);
Row r = s.getRow(0);
System.out.println("Cell A1 is " + r.getCell(0));

关于java - org.apache.poi.poifs.filesystem.OfficeXmlFileException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11790789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com