List of usage examples for org.apache.poi.xwpf.model XWPFHeaderFooterPolicy DEFAULT
Enum DEFAULT
To view the source code for org.apache.poi.xwpf.model XWPFHeaderFooterPolicy DEFAULT.
Click Source Link
From source file:File.DOCX.WriteDocx.java
public void CreateHeader(String header) { try {// ww w .j av a 2 s . c om CTP ctpHeader = CTP.Factory.newInstance(); CTR ctrHeader = ctpHeader.addNewR(); CTText ctHeader = ctrHeader.addNewT(); ctHeader.setStringValue(header); XWPFParagraph headerParagraph = new XWPFParagraph(ctpHeader, docx); XWPFParagraph[] parsHeader = new XWPFParagraph[1]; parsHeader[0] = headerParagraph; policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, parsHeader); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:File.DOCX.WriteDocx.java
public void CreateFooter(String footer) { try {/*from w ww . j a v a2s . c om*/ CTP ctpFooter = CTP.Factory.newInstance(); CTR ctrFooter = ctpFooter.addNewR(); CTText ctFooter = ctrFooter.addNewT(); // String footerText = "This is footer"; ctFooter.setStringValue(footer); XWPFParagraph footerParagraph = new XWPFParagraph(ctpFooter, docx); XWPFParagraph[] parsFooter = new XWPFParagraph[1]; parsFooter[0] = footerParagraph; policy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, parsFooter); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:offishell.word.Word.java
License:MIT License
/** * <p>/*from w w w .java 2 s . c o m*/ * Create header with the specified text. * </p> * * @param headerText A header text. */ public Word header(String headerText) { try { CTSectPr section = calculated.getDocument().getBody().addNewSectPr(); XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(calculated, section); XWPFHeader header = policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT); XWPFParagraph para = header.createParagraph(); XWPFRun run = para.createRun(); run.setText(headerText); styles().base().apply(run); } catch (Exception e) { throw I.quiet(e); } return this; }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
/** * Footer title/*from ww w . j a v a 2 s . c o 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); }
From source file:org.cgiar.ccafs.marlo.utils.POISummary.java
License:Open Source License
/** * Header title//from w ww .j a va 2 s. co m * * @param document * @param text * @throws IOException */ public void pageHeader(XWPFDocument document, String text) throws IOException { CTSectPr sectPr = document.getDocument().getBody().addNewSectPr(); XWPFHeaderFooterPolicy policy = new XWPFHeaderFooterPolicy(document, sectPr); CTP ctpHeader = CTP.Factory.newInstance(); CTR ctrHeader = ctpHeader.addNewR(); CTText ctHeader = ctrHeader.addNewT(); ctHeader.setStringValue(text); XWPFParagraph headerParagraph = new XWPFParagraph(ctpHeader, document); headerParagraph.setAlignment(ParagraphAlignment.RIGHT); XWPFParagraph[] parsHeader = new XWPFParagraph[1]; parsHeader[0] = headerParagraph; policy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, parsHeader); }