Bug 57366 - XWPFTable to Header / Footer
Summary: XWPFTable to Header / Footer
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XWPF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-18 17:54 UTC by Dommschwenker
Modified: 2016-10-30 18:55 UTC (History)
0 users



Attachments
mylyn/context/zip (163.96 KB, application/octet-stream)
2016-10-30 18:55 UTC, Mark Murphy
Details

Note You need to log in before you can comment on or make changes to this bug.
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