poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Weber <torstenweber84...@gmail.com>
Subject Reset numbering in a list
Date Wed, 17 Feb 2016 12:24:17 GMT
Hello,


if I have two lists, how do I reset the numbering to start at 1?

Example:

1. a
2. a
3. a

1. b
2. b
3. b


In the example below, the second list continues counting:
..

4. b
5. b
6. b


public class Example {
    private static XWPFNumbering numbering;

    public static void main(String[] args)throws Exception
    {
        XWPFDocument document= new XWPFDocument();
        FileOutputStream out = new FileOutputStream(new File("test.docx"));

        numbering = document.createNumbering();

        XWPFParagraph paragraph;

        for(int i = 1; i <= 6; i++) {
            paragraph = document.createParagraph();
            BigInteger numId = numbering.addNum(BigInteger.valueOf(0));
            paragraph.setNumID(numId);
            paragraph.getCTP().getPPr().getNumPr().addNewIlvl().setVal(BigInteger.valueOf(1));
            XWPFRun run=paragraph.createRun();
            run.setText(String.valueOf(i));

            if(i == 3) {
                // Reset numbering. Start by 1.

*                // ..*

            }
        }


        document.write(out);
        out.close();
    }
}



Thanks!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message