gpt4 book ai didi

java - 从Word文档中获取文档摘要信息

转载 作者:行者123 更新时间:2023-12-02 05:12:49 26 4
gpt4 key购买 nike

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class Init {

public static void main ( String[] argc ) throws IOException {
HWPFDocument myWorkBook = new HWPFDocument(
new POIFSFileSystem(
new FileInputStream("/home/jashka/Лаби/6.docx")));

System.out.println(myWorkBook.getDocumentSummaryInformation());
}
}

错误消息:

Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException:
The supplied data appears to be in the Office 2007+ XML. You are calling the part
of POI that deals with OLE2 Office Documents. You need to call a different part of POI
to process this data (eg XSSF instead of HSSF)

最佳答案

使用 XWPFDocument 而不是 HWPFDocument。

关于java - 从Word文档中获取文档摘要信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27203801/

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