Hi everybody,
I'm using apache poi of version 3.7 to create docx files, or to be more
precise to modify existing documents.
I'm facing following issue: if I apply any change to children list (e.g.
list of XWPFRun for XWPFParagraph) I'm the list is not refreshed, yet the
changes are applied. For Instance:
I have XWPFParagraph par with 3 runs inside, so that:
par.getRuns().size(); //returns 3
then I add a new run at the end:
par.createRun();
par.getRuns.size(); //returns 3, however 4 is expected.
the same with rows in table, the same with deletion of runs in paragraph.
However, when I execute document.write(..); The modified content is saved
successfully.
So the question is: if it's possible to synchronize java representation, and
structure which lies underneath. Since as I can see (XWPFParagraph code):
public XWPFRun createRun() {
return new XWPFRun(paragraph.addNewR(), this); //paragraph is of type
CTP here
}
No changes are applied to runs list.
Lurking deeper in the code shows that for creating paragraphs inside table
cell additional actions are taken:
public XWPFParagraph addParagraph() {
XWPFParagraph p = new XWPFParagraph(ctTc.addNewP(), this);
addParagraph(p);
return p;
}
public void addParagraph(XWPFParagraph p){
paragraphs.add(p);
}
Should it be the same way all around?
--
Best Regards,
Dmitry Kochelaev