I\'ve read many blogs and forums related to my requirement, but till now I was able to generate bullet or numbering for first level with all the help I got. Can anyone guide
You are right Apache POI has the worst kind of documentation or you can say no documentation at all. So there is nothing much you can find except a few blogs.
Replace your for loop with:
for (String value : content.split("@")) {
XWPFParagraph para = doc.createParagraph();
para.setVerticalAlignment(TextAlignment.CENTER);
para.setNumID(addListStyle(abstractNum, doc, numbering));
if (value.contains("Second")) {
para.getCTP().getPPr().getNumPr().addNewIlvl().setVal(BigInteger.valueOf(1));
}
XWPFRun run = para.createRun();
run.setText(value);
}
Create a multi hierarchy bullited list in MS-Word .docx
manually and inspect its XML structure by renaming its extension to .zip
, inside this zip you'll find word/document.xml
, by inspecting it you'll find that its <w:ilvl w:val="0"/>
, "ilvl" Indent Level that is responsible for you indentation so using above code you can create you multi level lists.
Here is how you set indent level:
para.getCTP().getPPr().getNumPr().addNewIlvl().setVal(BigInteger.valueOf(1));
Just increase indent level by BigInteger.valueOf((int)IndentLevel)