我的代码:
Document document = new Document();
Section section = new Section(document);
Body body = new Body(document);
document.removeAllChildren();
section.appendChild(body);
document.appendChild(section);
//第一层
Paragraph paragraph = new Paragraph(document);
paragraph.appendChild(new Run(document, "000"));
ListFormat listFormat = paragraph.getListFormat();
listFormat.applyNumberDefault();
//第二层
Paragraph paragraph1 = new Paragraph(document);
paragraph1.appendChild(new Run(document, "111"));
ListFormat listFormat1 = paragraph1.getListFormat();
listFormat1.applyNumberDefault();
listFormat1.listIndent();
Paragraph paragraph2 = new Paragraph(document);
paragraph2.appendChild(new Run(document, "222"));
ListFormat listFormat2 = paragraph2.getListFormat();
listFormat2.applyNumberDefault();
listFormat2.listIndent();
body.appendChild(paragraph);
body.appendChild(paragraph1);
body.appendChild(paragraph2);
document.save("./file/1.docx");
我生成的文件:
1.docx (8.0 KB)
我生成了一个docx文件,里面有一个有序列表,并且是两级,我想手动设置序号的样式(比如1,或者a,或者一),另外我发现同一级下,没有自增序号