Here is an example of code:
- Code: Select all
template = WordprocessingMLPackage.load(this.getClass().getClassLoader().getResourceAsStream(templatePath));
MainDocumentPart documentPart = template.getMainDocumentPart();
documentPart.addStyledParagraphOfText("Heading1", "test1");
documentPart.addStyledParagraphOfText("Heading1", "test2");
documentPart.addStyledParagraphOfText("Heading1", "test3");
The output looks like this:
1. test1
2. test2
3. test3
The "Heading1" style in the template(template is empty docx file) doesn't have numbering.