It is highly likely that I am incorrect, but I very much doubt that this is possible using POI; I have been following a couple of discussions relating to Microsoft's own OOXML SDK and even it has problems with this operation. To be able to determine where each section falls - i.e. it's page number - the document needs to be formatted into pages and this is something that is only done when the file is rendered. Thinking about it further, even when using Word itself, you need to explicitly tell the application to update the TOC - press F9 for instance - so even Word does not update the TOC automatically, as the document is being generated. My suggestion would be to base all of your documents on a template that includes a VBA macro which will run when the document is opened; this macro should include code to update the TOC. The one obvious problem with this is that the user can choose to disable macros and your standards may prohibit including trusted macros into documents to circumvent this problem.
Yours Mark B PS. I have heard that the TOC will be updated when the document is prepared for printing but do not know if this will help in any way. -- View this message in context: http://apache-poi.1045710.n5.nabble.com/word-document-update-filed-functionality-implement-in-POI-word-document-generation-tp5710363p5710364.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]
