相关疑难解决方法(0)

如何使用 Apache POI 为 docx 文件中的段落设置标题样式?

我正在尝试使用 poi 创建一个 docx 文件,但我无法为段落设置标题样式。

XWPFDocument document= new XWPFDocument(); 

//Write the Document in file system
FileOutputStream out = new FileOutputStream(new File("C:/Users/2/Desktop/RequirementModelDocument.docx"));

XWPFParagraph paragraph = document.createParagraph();
XWPFRun run=paragraph.createRun();


paragraph.setAlignment(ParagraphAlignment.LEFT);
paragraph.setStyle("Heading1");

run.setText(reqLevel.getName());
run.setBold(true);
run.setFontFamily("Calibri Light (Headings)");
Run Code Online (Sandbox Code Playgroud)

它就像忽略了这paragraph.setStyle("Heading1");条线。我看过 apache 的例子,但我看不到任何关于这个问题的例子。

java file docx apache-poi

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

apache-poi ×1

docx ×1

file ×1

java ×1