You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Hannes Erven <ha...@erven.at> on 2019/10/31 21:42:43 UTC
XWPFParagraph setters and need to check for PPr?
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-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org