List of usage examples for org.apache.poi.xwpf.model XWPFHeaderFooterPolicy createFooter
public XWPFFooter createFooter(Enum type, XWPFParagraph[] pars)
From source file:org.cgiar.ccafs.marlo.action.summaries.AnualReportPOISummaryAction.java
License:Open Source License
public void createPageFooter() { CTP ctp = CTP.Factory.newInstance(); // this add page number incremental ctp.addNewR().addNewPgNum();/*from ww w . ja v a 2 s . c o m*/ XWPFParagraph codePara = new XWPFParagraph(ctp, document); XWPFParagraph[] paragraphs = new XWPFParagraph[1]; paragraphs[0] = codePara; // position of number codePara.setAlignment(ParagraphAlignment.CENTER); CTSectPr sectPr = document.getDocument().getBody().addNewSectPr(); try { XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr); headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, paragraphs); } catch (IOException e) { LOG.error("Failed to createFooter. Exception: " + e.getMessage()); } }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
/** * Footer title/*from ww w .j a va 2s. co m*/ * * @param document * @param text * @throws IOException */ public void pageFooter(XWPFDocument document, String text) throws IOException { CTSectPr sectPr = document.getDocument().getBody().addNewSectPr(); XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr); CTP ctpFooter = CTP.Factory.newInstance(); CTR ctrFooter = ctpFooter.addNewR(); CTText ctFooter = ctrFooter.addNewT(); ctFooter.setStringValue(text); XWPFParagraph footerParagraph = new XWPFParagraph(ctpFooter, document); footerParagraph.setAlignment(ParagraphAlignment.LEFT); XWPFParagraph[] parsFooter = new XWPFParagraph[1]; parsFooter[0] = footerParagraph; policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, parsFooter); }