Bug 57366

Summary: XWPFTable to Header / Footer
Product: POI Reporter: Dommschwenker <dommschwenker>
Component: XWPFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: mylyn/context/zip

Description Dommschwenker 2014-12-18 17:54:42 UTC
Hello,

how can I create a table in the footer?



For text I find this:

CTP ctp = CTP.Factory.newInstance();
CTR ctr = ctp.addNewR();
CTRPr rpr = ctr.addNewRPr();
CTText textt = ctr.addNewT();
textt.setStringValue(" - Page 1 - ");
XWPFParagraph codePara = new XWPFParagraph(ctp, document);
XWPFParagraph[] newparagraphs = new XWPFParagraph[1];
newparagraphs[0] = codePara;
CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, newparagraphs);


Version: poi-3.12-beta1

Thanks
Comment 1 Mark Murphy 2016-10-30 18:55:03 UTC
Fixed by r1767175. This contains a breaking change. Creating a new header of footer no longer defaults to adding an empty paragraph when no paragraphs are provided. This facilitates adding a Table as the first block element of the header or footer. If no block elements are added to the header or footer, then an empty paragraph will be added automatically when the document is saved to prevent writing a corrupt document.
Comment 2 Mark Murphy 2016-10-30 18:55:06 UTC
Created attachment 34411 [details]
mylyn/context/zip