如何从Apache POI获取脚注和段落? [英] How can I get footnotes and paragraphs from Apache POI?
本文介绍了如何从Apache POI获取脚注和段落?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有代码从Apache POI中的.doc文件中获取段落,但我也想得到脚注。另外,这是获取段落的唯一方法吗?
I have code to get paragraphs from a .doc file in Apache POI, but I'd like to get footnotes also. Also, is this the only way to get paragraphs?
到目前为止的代码:
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();
}
任何想法?
推荐答案
你可以尝试这个......
You could try this...
WordExtractor extractor = new WordExtractor(document);
paragraphs.addAll(Arrays.asList(extractor.getParagraphText()) );
footnotes.addAll(Arrays.asList(extractor.getFootnoteText()) );
extractor.close();
这篇关于如何从Apache POI获取脚注和段落?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文