ms word - how to setup an AbstractNumbering for bulleted Lists -
i want generate unordered lists in word document docx4j
. can give me example of abstractnumbering
bulleted lists?
public void setabstractnumbering(){ try { numberingdefinitionspart ndp = new numberingdefinitionspart(); myword.addtargetpart(ndp); numbering.abstractnum abstractnum = factory.createnumberingabstractnum(); abstractnum.setabstractnumid(biginteger.valueof(1)); numbering.abstractnum.multileveltype multileveltype = new numbering.abstractnum.multileveltype(); abstractnum.setmultileveltype(multileveltype); multileveltype.setval("singlelevel"); lvl lvl = factory.createlvl(); abstractnum.getlvl().add(lvl); lvl.setilvl(biginteger.valueof(0)); lvl.start start = new lvl.start(); lvl.setstart(start); start.setval(biginteger.valueof(1)); numfmt numfmt = factory.createnumfmt(); lvl.setnumfmt(numfmt); numfmt.setval(numberformat.bullet); lvl.lvltext text = new lvl.lvltext(); lvl.setlvltext(text); text.setval("%1"); numbering.num numbering = ndp.addabstractlistnumberingdefinition(abstractnum); numbering.num.abstractnumid abstractnumid = new numbering.num.abstractnumid(); abstractnumid.setval(biginteger.valueof(1)); numbering.setabstractnumid(abstractnumid); numbering.setnumid(biginteger.valueof(3)); } catch (invalidformatexception ife){ ife.printstacktrace(); } }
i'm getting nullpointerexception
when adding abstractnumbering
numberingdefinitionspart
. know i'm doing wrong?
you need numbering definition instance points it; see further ecma376/wordml/numbering_2.html
the easiest way code create simple docx in word, use docx4j webapp or helper word addin generate code numbering definitions part in docx.
Comments
Post a Comment