Hi,

I've downloaded POI 4.1.1 and am trying to keep some paragraphs of a Word document together.

For a "regular" paragraph, this is fairly easy:
        para.setKeepNext(true);

My document also has a table with several rows, and I would also like to keep some of those together. But:
        XWPFTable table = document.createTable(3, 2);
        //...
        XWPFTableRow row = table.getRow(0);
        XWPFParagraph p0 = row.getCell(0).getParagraphArray(0);
        p0.setKeepNext(true);

throws a NullPointerException in XWPFParagraph line 426.

Looking at the sources, getCTP().getPPR() is null. When I insert these lines just before setKeepNext():

        CTP ctP = p0.getCTP();
        if (! ctP.isSetPPr()) ctP.addNewPPr();

... it works.


Is this expected?


Thank you very much,
best regards

        -hannes


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to