我有代码从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();
}
有什么想法吗?
答案 0 :(得分:3)
你可以试试这个......
WordExtractor extractor = new WordExtractor(document);
paragraphs.addAll(Arrays.asList(extractor.getParagraphText()) );
footnotes.addAll(Arrays.asList(extractor.getFootnoteText()) );
extractor.close();