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. If somebody can point me in the right direction I would happy to try to write a patch.
Good spot, thanks, fix applied in r1614930.