You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by emberey <cl...@cgi.com> on 2013/07/03 14:23:12 UTC

XWPFDocument createTOC

Version 3.9

OpenXML Word Documents.

Using createTOC will raise an exception if any of your styles are less than
7 characters. This is caused by the method createTOC and the line

            if (parStyle != null && parStyle.substring(0,
7).equals("Heading")) {

Quick fix is to extend this class and override createTOC. The line should be
something like

            if (parStyle != null && parStyle.startsWith("Heading")) {

Also remember to position to the location you want the TOC to be inserted.

My first post so I wasn't sure where to post. 

Hope this helps someone.



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/XWPFDocument-createTOC-tp5713176.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: XWPFDocument createTOC

Posted by Nick Burch <ap...@gagravarr.org>.
On Wed, 3 Jul 2013, emberey wrote:
> Version 3.9
>
> OpenXML Word Documents.
>
> Using createTOC will raise an exception if any of your styles are less than
> 7 characters. This is caused by the method createTOC and the line
>
>            if (parStyle != null && parStyle.substring(0,
> 7).equals("Heading")) {

Any chance you could open a bug in bugzilla for this? Bonus marks if you 
could also upload the patch that fixes it as per your email, and/or a unit 
test that shows the problem!

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org