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

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

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

XWPFHeaderFooterPolicy.getDefaultFooter介绍

暂无

代码示例

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

private void extractFooters(StringBuilder text, XWPFHeaderFooterPolicy hfPolicy) {
  if (hfPolicy == null) return;
  if (hfPolicy.getFirstPageFooter() != null) {
    text.append(hfPolicy.getFirstPageFooter().getText());
  }
  if (hfPolicy.getEvenPageFooter() != null) {
    text.append(hfPolicy.getEvenPageFooter().getText());
  }
  if (hfPolicy.getDefaultFooter() != null) {
    text.append(hfPolicy.getDefaultFooter().getText());
  }
}

代码示例来源:origin: apache/tika

private void extractFooters(
    XHTMLContentHandler xhtml, XWPFHeaderFooterPolicy hfPolicy,
    XWPFListManager listManager)
    throws SAXException, XmlException, IOException {
  // footers
  if (hfPolicy.getFirstPageFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getFirstPageFooter(), listManager);
  }
  if (hfPolicy.getEvenPageFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getEvenPageFooter(), listManager);
  }
  if (hfPolicy.getDefaultFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getDefaultFooter(), listManager);
  }
}

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

private void extractFooters(StringBuilder text, XWPFHeaderFooterPolicy hfPolicy) {
  if (hfPolicy == null) return;
  if (hfPolicy.getFirstPageFooter() != null) {
    text.append(hfPolicy.getFirstPageFooter().getText());
  }
  if (hfPolicy.getEvenPageFooter() != null) {
    text.append(hfPolicy.getEvenPageFooter().getText());
  }
  if (hfPolicy.getDefaultFooter() != null) {
    text.append(hfPolicy.getDefaultFooter().getText());
  }
}

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

private void extractFooters(StringBuffer text, XWPFHeaderFooterPolicy hfPolicy) {
  if(hfPolicy.getFirstPageFooter() != null) {
    text.append( hfPolicy.getFirstPageFooter().getText() );
  }
  if(hfPolicy.getEvenPageFooter() != null) {
    text.append( hfPolicy.getEvenPageFooter().getText() );
  }
  if(hfPolicy.getDefaultFooter() != null) {
    text.append( hfPolicy.getDefaultFooter().getText() );
  }
}

代码示例来源:origin: com.github.lafa.tikaNoExternal/tika-parsers

private void extractFooters(
    XHTMLContentHandler xhtml, XWPFHeaderFooterPolicy hfPolicy,
    XWPFListManager listManager)
    throws SAXException, XmlException, IOException {
  // footers
  if (hfPolicy.getFirstPageFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getFirstPageFooter(), listManager);
  }
  if (hfPolicy.getEvenPageFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getEvenPageFooter(), listManager);
  }
  if (hfPolicy.getDefaultFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getDefaultFooter(), listManager);
  }
}

代码示例来源:origin: org.apache.tika/tika-parsers

private void extractFooters(
    XHTMLContentHandler xhtml, XWPFHeaderFooterPolicy hfPolicy,
    XWPFListManager listManager)
    throws SAXException, XmlException, IOException {
  // footers
  if (hfPolicy.getFirstPageFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getFirstPageFooter(), listManager);
  }
  if (hfPolicy.getEvenPageFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getEvenPageFooter(), listManager);
  }
  if (hfPolicy.getDefaultFooter() != null) {
    extractHeaderText(xhtml, hfPolicy.getDefaultFooter(), listManager);
  }
}

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

public void test1() throws IOException{

  XWPFDocument sampleDoc = new XWPFDocument();
  XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();
  //in an empty document always will be null
  if(policy==null){
    CTSectPr sectPr = sampleDoc.getDocument().getBody().addNewSectPr();
    policy = new  XWPFHeaderFooterPolicy( sampleDoc, sectPr );
  }

  if (policy.getDefaultHeader() == null && policy.getFirstPageHeader() == null
      && policy.getDefaultFooter() == null) {
    XWPFHeader headerD = policy.createHeader(policy.DEFAULT);
    headerD.getParagraphs().get(0).createRun().setText("Hello Header World!");

  } 
  FileOutputStream out = new FileOutputStream(System.currentTimeMillis()+"_test1_header.docx");
  sampleDoc.write(out);
  out.close();
  sampleDoc.close();
}

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

XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();
if (policy.getDefaultHeader() == null && policy.getFirstPageHeader() == null
    && policy.getDefaultFooter() == null) {
  // Need to create some new headers
  // The easy way, gives a single empty paragraph
  XWPFHeader headerD = policy.createHeader(policy.DEFAULT);
  headerD.getParagraphs(0).createRun().setText("Hello Header World!");

  // Or the full control way
  CTP ctP1 = CTP.Factory.newInstance();
  CTR ctR1 = ctP1.addNewR();
  CTText t = ctR1.addNewT();
  t.setStringValue("Paragraph in header");

  XWPFParagraph p1 = new XWPFParagraph(ctP1, sampleDoc);
  XWPFParagraph[] pars = new XWPFParagraph[1];
  pars[0] = p1;

  policy.createHeader(policy.FIRST, pars);
} else {
  // Already has a header, change it
}

相关文章