编程语言
首页 > 编程语言> > java-如何从Apache POI获得脚注和段落?

java-如何从Apache POI获得脚注和段落?

作者:互联网

我有从Apache POI中的.doc文件获取段落的代码,但我也想获取脚注.另外,这是获取段落的唯一方法吗?

到目前为止的代码:

    InputStream stream = ...
    HWPFDocument document = new HWPFDocument(stream);
    Range range = document.getRange();

    StyleSheet stylesheet = document.getStyleSheet();

    for (int i = 0; i < range.numParagraphs(); i++) {
        Paragraph paragraph = range.getParagraph(i);

        String text = paragraph.text();
    }

有任何想法吗?

解决方法:

你可以试试这个…

WordExtractor extractor = new WordExtractor(document);
paragraphs.addAll(Arrays.asList(extractor.getParagraphText()) ); 
footnotes.addAll(Arrays.asList(extractor.getFootnoteText()) );
extractor.close();

标签:apache-poi,java
来源: https://codeday.me/bug/20191118/2031308.html