本文概述
- Apache POI Word段落示例
让我们看一个示例,其中我们创建段落并将其写入Word文件。
Apache POI Word段落示例
package poiexample;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
public class ParagraphExample {
public static void main(String[] args) {
XWPFDocument doc = new XWPFDocument();
try(OutputStream os = new FileOutputStream("srcmini.doc")) {
XWPFParagraph paragraph = doc.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("Hello, This is srcmini. This paragraph is written "+
"by using XWPFParagrah.");
doc.write(os);
}catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
【apache poi word文档段落】输出:
文章图片
推荐阅读
- apache poi powerpoint幻灯片
- apache poi超链接
- apache poi word表格
- apache poi word风格
- apache poi word对齐
- apache poi word提取文本
- apache poi word提取段落
- apache poi和powerpoint
- apache poi创建ms word文档