本文概述
- Apache POI提取段落示例
让我们看一个使用Java程序提取段落的示例。
Apache POI提取段落示例
package poiexample;
import java.io.FileInputStream;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
public class ReadParagraphExample {
public static void main(String[] args) {
try(FileInputStream fis = new FileInputStream("srcmini.docx")) {
XWPFDocument doc= new XWPFDocument(OPCPackage.open(fis));
java.util.List<
XWPFParagraph> paragraphs =doc.getParagraphs();
for (XWPFParagraph paragraph: paragraphs){
System.out.println(paragraph.getText());
}
}catch(Exception e) {
System.out.println(e);
}
}
}
【apache poi word提取段落】输入:
文章图片
输出:
Apache POI (Poor Obfuscation Implementation) is a project design and developed by Apache Software
Foundation. It is a collection of pure Java libraries, used to read and write Microsoft office
files such as Word, PowerPoint etc. The purpose was to design a cross-platform API that can
manipulate various file formats of Microsoft Office and Open Office Documents.
推荐阅读
- apache poi word提取文本
- apache poi和powerpoint
- apache poi创建ms word文档
- apache poi microsoft word文档
- apache poi的注释
- apache poi样式化形状
- apache poi重写
- apache poi读取单元内容
- apache poi移位行