我正在尝试使用 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 的例子,但我看不到任何关于这个问题的例子。