https://bz.apache.org/bugzilla/show_bug.cgi?id=66363
Nigel Gay <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- OS| |All --- Comment #1 from Nigel Gay <[email protected]> --- The only workaround I can find is to create an XmlCursor for the insertion point, then call XWPFDocument.insertNewTbl to create a throwaway table, then use XWPFDocument.setTable to replace the throwaway table with the real one. public XmlCursor newCursorForBodyElement (IBodyElement elem) { XmlCursor cursor; if (elem instanceof XWPFParagraph) { XWPFParagraph para = (XWPFParagraph) elem; cursor = para.getCTP ().newCursor (); } else if (elem instanceof XWPFTable) { XWPFTable table = (XWPFTable) elem; cursor = table.getCTTbl ().newCursor (); } else throw new RuntimeException ("Don't know how to create a cursor from body element of type " + elem.getClass ()); return cursor; } .. and then can do ... index = 3; XWPFTable throwawayTable; if (index < doc.getBodyElements ().size ()) { // Insert before numbered element XmlCursor insertionPoint = newCursorForBodyElement (doc.getBodyElements ().get (index)); throwawayTable = doc.insertNewTbl (insertionPoint); } else { // Insert at end throwawayTable = doc.createTable (); } doc.setTable (doc.getTables ().indexOf (throwawayTable), dest); -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
