org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.createFooter()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.createFooter()方法的一些代码示例,展示了XWPFHeaderFooterPolicy.createFooter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFHeaderFooterPolicy.createFooter()方法的具体详情如下:
包路径:org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy
类名称:XWPFHeaderFooterPolicy
方法名:createFooter

XWPFHeaderFooterPolicy.createFooter介绍

[英]Creates an empty footer of the specified type, containing a single empty paragraph, to which you can then set text, add more paragraphs etc.
[中]创建指定类型的空页脚,其中包含一个空段落,然后可以在其中设置文本、添加更多段落等。

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * Creates an empty footer of the specified type, containing a single
  3. * empty paragraph, to which you can then set text, add more paragraphs etc.
  4. */
  5. public XWPFFooter createFooter(Enum type) {
  6. return createFooter(type, null);
  7. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * Create a footer of the given type
  3. *
  4. * @param type {@link HeaderFooterType} enum
  5. * @return object of type {@link XWPFFooter}
  6. */
  7. public XWPFFooter createFooter(HeaderFooterType type) {
  8. XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy();
  9. // TODO this needs to be migrated out into section code
  10. if (type == HeaderFooterType.FIRST) {
  11. CTSectPr ctSectPr = getSection();
  12. if (!ctSectPr.isSetTitlePg()) {
  13. CTOnOff titlePg = ctSectPr.addNewTitlePg();
  14. titlePg.setVal(STOnOff.ON);
  15. }
  16. // } else if (type == HeaderFooterType.EVEN) {
  17. // TODO Add support for Even/Odd headings and footers
  18. }
  19. return hfPolicy.createFooter(STHdrFtr.Enum.forInt(type.toInt()));
  20. }

代码示例来源:origin: youseries/ureport

  1. public void build(XWPFDocument document,CTSectPr sectPr,Report report){
  2. //HeaderFooterDefinition headerDef=report.getHeader();
  3. //HeaderFooterDefinition footerDef=report.getFooter();
  4. HeaderFooter header=new HeaderFooter();
  5. HeaderFooter footer=new HeaderFooter();
  6. XWPFHeaderFooterPolicy headerFooterPolicy=null;
  7. if(header!=null){
  8. List<XWPFParagraph> list=buildXWPFParagraph(header, document);
  9. XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
  10. list.toArray(newparagraphs);
  11. headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
  12. headerFooterPolicy.createHeader(STHdrFtr.DEFAULT, newparagraphs);
  13. }
  14. if(footer!=null){
  15. List<XWPFParagraph> list=buildXWPFParagraph(footer, document);
  16. XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
  17. list.toArray(newparagraphs);
  18. /*if(headerFooterPolicy==null){
  19. headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
  20. }*/
  21. headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, newparagraphs);
  22. }
  23. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

  1. /**
  2. * Creates an empty footer of the specified type, containing a single
  3. * empty paragraph, to which you can then set text, add more paragraphs etc.
  4. */
  5. public XWPFFooter createFooter(Enum type) {
  6. return createFooter(type, null);
  7. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. public XWPFFooter createFooter(Enum type) throws IOException {
  2. return createFooter(type, null);
  3. }

代码示例来源:origin: stackoverflow.com

  1. CTP ctp = CTP.Factory.newInstance();
  2. CTR ctr = ctp.addNewR();
  3. CTRPr rpr = ctr.addNewRPr();
  4. CTText textt = ctr.addNewT();
  5. textt.setStringValue( " Page 1" );
  6. XWPFParagraph codePara = new XWPFParagraph( ctp, document );
  7. XWPFParagraph[] newparagraphs = new XWPFParagraph[1];
  8. newparagraphs[0] = codePara;
  9. CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
  10. XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy( document, sectPr );
  11. headerFooterPolicy.createFooter( STHdrFtr.DEFAULT, newparagraphs );

代码示例来源:origin: stackoverflow.com

  1. String text = "Test";
  2. File docxFile = new File("C:/testeXWPF.docx");
  3. FileInputStream finStream = new FileInputStream(docxFile.getAbsolutePath());
  4. XWPFDocument doc = new XWPFDocument(finStream);
  5. XWPFHeaderFooterPolicy policy = doc.getHeaderFooterPolicy();
  6. if (policy == null) {
  7. policy = new XWPFHeaderFooterPolicy(doc);
  8. }
  9. CTP ctP1 = CTP.Factory.newInstance();
  10. CTR ctR1 = ctP1.addNewR();
  11. CTText t = ctR1.addNewT();
  12. t.setStringValue(text);
  13. XWPFParagraph codePara = new XWPFParagraph(ctP1);
  14. XWPFParagraph[] newparagraphs = new XWPFParagraph[1];
  15. newparagraphs[0] = codePara;
  16. policy.createFooter(policy.DEFAULT, newparagraphs);
  17. FileOutputStream fileOut = new FileOutputStream(docxFile);
  18. doc.write(fileOut);
  19. fileOut.close();

代码示例来源:origin: stackoverflow.com

  1. XWPFDocument document = new XWPFDocument();
  2. CTP ctp = CTP.Factory.newInstance();
  3. CTR ctr = ctp.addNewR();
  4. CTRPr rpr = ctr.addNewRPr();
  5. CTText textt = ctr.addNewT();
  6. textt.setStringValue( " Page 1" );
  7. XWPFParagraph codePara = new XWPFParagraph( ctp, document );
  8. XWPFParagraph[] newparagraphs = new XWPFParagraph[1];
  9. newparagraphs[0] = codePara;
  10. CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
  11. XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy( document, sectPr );
  12. headerFooterPolicy.createFooter( STHdrFtr.DEFAULT, newparagraphs );

代码示例来源:origin: com.bstek.ureport/ureport2-core

  1. public void build(XWPFDocument document,CTSectPr sectPr,Report report){
  2. //HeaderFooterDefinition headerDef=report.getHeader();
  3. //HeaderFooterDefinition footerDef=report.getFooter();
  4. HeaderFooter header=new HeaderFooter();
  5. HeaderFooter footer=new HeaderFooter();
  6. XWPFHeaderFooterPolicy headerFooterPolicy=null;
  7. if(header!=null){
  8. List<XWPFParagraph> list=buildXWPFParagraph(header, document);
  9. XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
  10. list.toArray(newparagraphs);
  11. headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
  12. headerFooterPolicy.createHeader(STHdrFtr.DEFAULT, newparagraphs);
  13. }
  14. if(footer!=null){
  15. List<XWPFParagraph> list=buildXWPFParagraph(footer, document);
  16. XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
  17. list.toArray(newparagraphs);
  18. /*if(headerFooterPolicy==null){
  19. headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
  20. }*/
  21. headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, newparagraphs);
  22. }
  23. }

代码示例来源:origin: stackoverflow.com

  1. // create footer components
  2. XWPFDocument document = new XWPFDocument();
  3. CTP footerCtp = CTP.Factory.newInstance();
  4. CTR footerCtr = footerCtp.addNewR();
  5. XWPFParagraph footerCopyrightParagraph = new XWPFParagraph(footerCtp, document);
  6. document.getProperties().getExtendedProperties().getUnderlyingProperties().getPages();
  7. XWPFRun run = footerCopyrightParagraph.getRun(footerCtr);
  8. run.setText("My Website.com");
  9. run.addTab();
  10. run.setText("\u00A9" + " My Website - " + Calendar.getInstance().get(Calendar.YEAR));
  11. run.addTab();
  12. run.setText("Right Side Text");
  13. setTabStop(footerCtp, STTabJc.Enum.forString("right"), BigInteger.valueOf(9000));
  14. XWPFParagraph[] footerParagraphs = {footerCopyrightParagraph};
  15. CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
  16. XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
  17. headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, footerParagraphs);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

  1. /**
  2. * Create a footer of the given type
  3. *
  4. * @param type {@link HeaderFooterType} enum
  5. * @return object of type {@link XWPFFooter}
  6. */
  7. public XWPFFooter createFooter(HeaderFooterType type) {
  8. XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy();
  9. // TODO this needs to be migrated out into section code
  10. if (type == HeaderFooterType.FIRST) {
  11. CTSectPr ctSectPr = getSection();
  12. if (!ctSectPr.isSetTitlePg()) {
  13. CTOnOff titlePg = ctSectPr.addNewTitlePg();
  14. titlePg.setVal(STOnOff.ON);
  15. }
  16. // } else if (type == HeaderFooterType.EVEN) {
  17. // TODO Add support for Even/Odd headings and footers
  18. }
  19. return hfPolicy.createFooter(STHdrFtr.Enum.forInt(type.toInt()));
  20. }

代码示例来源:origin: org.apache.poi/poi-examples

  1. t.setStringValue("My Footer");
  2. pars[0] = new XWPFParagraph(ctP, doc);
  3. hfPolicy.createFooter(XWPFHeaderFooterPolicy.DEFAULT, pars);

代码示例来源:origin: stackoverflow.com

  1. XWPFFooter footer = headerFooterPolicy.createFooter(XWPFHeaderFooterPolicy.DEFAULT);

代码示例来源:origin: stackoverflow.com

  1. XWPFFooter footer = headerFooterPolicy.createFooter(XWPFHeaderFooterPolicy.DEFAULT);

相关文章