I'm having serious trouble adding a new, simple XWPFTable to an XWPFHeader (or Footer). Unfortunately there seems to be only one guy having the same problem (https://bz.apache.org/bugzilla/show_bug.cgi?id=57366#c0).
Does anyone has an approach to achieve this??
XWPFDocument docx = (XWPFDocument) dockingObject;
CTSectPr sectPr = docx.getDocument().getBody().addNewSectPr();
XWPFHeaderFooterPolicy policy = new WPFHeaderFooterPolicy(docx, sectPr);
XWPFHeader header = policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT);
// somthing like: header.createTable();
Any help will be more than appreciated!
Kind regard...
~ Daniel
This is possible using public XWPFTable insertNewTbl(org.apache.xmlbeans.XmlCursor cursor).
Approach: Create a new paragraph in the header. Then get a
org.apache.xmlbeans.XmlCursor
from theorg.openxmlformats.schemas.wordprocessingml.x2006.main.CTP
of that paragraph. Then insert the table positioned by that cursor.Example: