本文整理了Java中org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy.createHeader()
方法的一些代码示例,展示了XWPFHeaderFooterPolicy.createHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWPFHeaderFooterPolicy.createHeader()
方法的具体详情如下:
包路径:org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy
类名称:XWPFHeaderFooterPolicy
方法名:createHeader
[英]Creates an empty header 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
/**
* Creates an empty header of the specified type, containing a single
* empty paragraph, to which you can then set text, add more paragraphs etc.
*/
public XWPFHeader createHeader(Enum type) {
return createHeader(type, null);
}
代码示例来源:origin: org.apache.poi/poi-ooxml
public void createWatermark(String text) {
XWPFParagraph[] pars = new XWPFParagraph[1];
pars[0] = getWatermarkParagraph(text, 1);
createHeader(DEFAULT, pars);
pars[0] = getWatermarkParagraph(text, 2);
createHeader(FIRST, pars);
pars[0] = getWatermarkParagraph(text, 3);
createHeader(EVEN, pars);
}
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Create a header of the given type
*
* @param type {@link HeaderFooterType} enum
* @return object of type {@link XWPFHeader}
*/
public XWPFHeader createHeader(HeaderFooterType type) {
XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy();
// TODO this needs to be migrated out into section code
if (type == HeaderFooterType.FIRST) {
CTSectPr ctSectPr = getSection();
if (!ctSectPr.isSetTitlePg()) {
CTOnOff titlePg = ctSectPr.addNewTitlePg();
titlePg.setVal(STOnOff.ON);
}
// } else if (type == HeaderFooterType.EVEN) {
// TODO Add support for Even/Odd headings and footers
}
return hfPolicy.createHeader(STHdrFtr.Enum.forInt(type.toInt()));
}
代码示例来源:origin: youseries/ureport
public void build(XWPFDocument document,CTSectPr sectPr,Report report){
//HeaderFooterDefinition headerDef=report.getHeader();
//HeaderFooterDefinition footerDef=report.getFooter();
HeaderFooter header=new HeaderFooter();
HeaderFooter footer=new HeaderFooter();
XWPFHeaderFooterPolicy headerFooterPolicy=null;
if(header!=null){
List<XWPFParagraph> list=buildXWPFParagraph(header, document);
XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
list.toArray(newparagraphs);
headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createHeader(STHdrFtr.DEFAULT, newparagraphs);
}
if(footer!=null){
List<XWPFParagraph> list=buildXWPFParagraph(footer, document);
XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
list.toArray(newparagraphs);
/*if(headerFooterPolicy==null){
headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
}*/
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, newparagraphs);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Creates an empty header of the specified type, containing a single
* empty paragraph, to which you can then set text, add more paragraphs etc.
*/
public XWPFHeader createHeader(Enum type) {
return createHeader(type, null);
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
public XWPFHeader createHeader(Enum type) throws IOException {
return createHeader(type, null);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
public void createWatermark(String text) {
XWPFParagraph[] pars = new XWPFParagraph[1];
pars[0] = getWatermarkParagraph(text, 1);
createHeader(DEFAULT, pars);
pars[0] = getWatermarkParagraph(text, 2);
createHeader(FIRST, pars);
pars[0] = getWatermarkParagraph(text, 3);
createHeader(EVEN, pars);
}
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
public void createWatermark(String text) {
XWPFParagraph[] pars = new XWPFParagraph[1];
try {
pars[0] = getWatermarkParagraph(text, 1);
createHeader(DEFAULT, pars);
pars[0] = getWatermarkParagraph(text, 2);
createHeader(FIRST, pars);
pars[0] = getWatermarkParagraph(text, 3);
createHeader(EVEN, pars);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
代码示例来源: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
}
代码示例来源:origin: com.bstek.ureport/ureport2-core
public void build(XWPFDocument document,CTSectPr sectPr,Report report){
//HeaderFooterDefinition headerDef=report.getHeader();
//HeaderFooterDefinition footerDef=report.getFooter();
HeaderFooter header=new HeaderFooter();
HeaderFooter footer=new HeaderFooter();
XWPFHeaderFooterPolicy headerFooterPolicy=null;
if(header!=null){
List<XWPFParagraph> list=buildXWPFParagraph(header, document);
XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
list.toArray(newparagraphs);
headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
headerFooterPolicy.createHeader(STHdrFtr.DEFAULT, newparagraphs);
}
if(footer!=null){
List<XWPFParagraph> list=buildXWPFParagraph(footer, document);
XWPFParagraph[] newparagraphs = new XWPFParagraph[list.size()];
list.toArray(newparagraphs);
/*if(headerFooterPolicy==null){
headerFooterPolicy = new XWPFHeaderFooterPolicy(document, sectPr);
}*/
headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, newparagraphs);
}
}
代码示例来源: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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Create a header of the given type
*
* @param type {@link HeaderFooterType} enum
* @return object of type {@link XWPFHeader}
*/
public XWPFHeader createHeader(HeaderFooterType type) {
XWPFHeaderFooterPolicy hfPolicy = createHeaderFooterPolicy();
// TODO this needs to be migrated out into section code
if (type == HeaderFooterType.FIRST) {
CTSectPr ctSectPr = getSection();
if (!ctSectPr.isSetTitlePg()) {
CTOnOff titlePg = ctSectPr.addNewTitlePg();
titlePg.setVal(STOnOff.ON);
}
// } else if (type == HeaderFooterType.EVEN) {
// TODO Add support for Even/Odd headings and footers
}
return hfPolicy.createHeader(STHdrFtr.Enum.forInt(type.toInt()));
}
代码示例来源:origin: org.apache.poi/poi-examples
hfPolicy.createHeader(XWPFHeaderFooterPolicy.DEFAULT, pars);
代码示例来源:origin: stackoverflow.com
XWPFHeader header = headerFooterPolicy.createHeader(XWPFHeaderFooterPolicy.DEFAULT);
代码示例来源:origin: stackoverflow.com
XWPFHeader header = headerFooterPolicy.createHeader(XWPFHeaderFooterPolicy.DEFAULT);
内容来源于网络,如有侵权,请联系作者删除!