I've got a document here (docx), where I'm adding some paragraphs and runs.
After adding these new headings, the document is written in a new docx and
saved. The Template.docx has already a table of content inserted, but after
I run the code, i get Export.docx with the two new headings but the table of
content is not up-to-date. I'll only see Chapter one and two.
Does somebody has a solution for this problem? Can i somehow "Reload" the
table of content before I save the document into a new file?
Code:
-------------------
File inFile = new File("Template.docx");
File outFile = new File("Export.docx");
FileInputStream inStream = new FileInputStream(inFile);
XWPFDocument doc = new XWPFDocument(inStream);
XWPFParagraph paragraphOne = doc.createParagraph();
paragraphOne.setStyle("heading1");
XWPFRun paragraphOneRunOne = paragraphOne.createRun();
paragraphOneRunOne.setText("Chapter three");
XWPFParagraph paragraphTwo = doc.createParagraph();
paragraphTwo.setStyle("heading2");
XWPFRun paragraphTwoRunOne = paragraphTwo.createRun();
paragraphTwoRunOne.setText("Subtitle of chapter three");
OutputStream out = new FileOutputStream(outFile);
doc.write(out);
out.flush();
out.close();
-------------------
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/Reload-Refresh-Table-of-Contents-tp5710076.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]