poi操作word 2007 常用方法总结(4)

2019-03-29 13:04

hightLight.setVal(hightStyle);

}

}

if (isShd) {

// 设置底纹

CTShd shd = rpr.addNewShd();

if (shdStyle != null) {

shd.setVal(shdStyle);

}

if (shdColor != null) {

shd.setColor(shdColor);

}

}

// 上标下标

if (verticalAlign != null) {

rpr.addNewVertAlign().setVal(verticalAlign);

}

// 设置文本位置

rpr.addNewPosition().setVal(new BigInteger(String.valueOf(position)));

if (spacingValue != 0) {

// 设置字符间距信息

CTSignedTwipsMeasure ctSTwipsMeasure = rpr.addNewSpacing();

ctSTwipsMeasure

.setVal(new BigInteger(String.valueOf(spacingValue)));

}

// 设置字符间距缩进

if (indent > 0) {

CTTextScale paramCTTextScale = rpr.addNewW();

paramCTTextScale.setVal(indent);

}

ctr.setTArray(new CTText[] { ctText });

cLink.setRArray(new CTR[] { ctr });

}

/*------------------------------------Word 页眉页脚相关--------------------------------------------------- */

/**

* @Description: 页脚:显示页码信息

*/

public void simpleNumberFooter(XWPFDocument document) throws Exception {

CTP ctp = CTP.Factory.newInstance();

XWPFParagraph codePara = new XWPFParagraph(ctp, document);

XWPFRun r1 = codePara.createRun();

r1.setText(\第\);

setParagraphRunFontInfo(codePara, r1, null, \微软雅黑\, \);

r1 = codePara.createRun();

CTFldChar fldChar = r1.getCTR().addNewFldChar();

fldChar.setFldCharType(STFldCharType.BEGIN);

r1 = codePara.createRun();

CTText ctText = r1.getCTR().addNewInstrText();

ctText.setStringValue(\);

ctText.setSpace(SpaceAttribute.Space.PRESERVE);

setParagraphRunFontInfo(codePara, r1, null, \微软雅黑\, \);

fldChar = r1.getCTR().addNewFldChar();

fldChar.setFldCharType(STFldCharType.END);

r1 = codePara.createRun();

r1.setText(\页 总共\);

setParagraphRunFontInfo(codePara, r1, null, \微软雅黑\, \);

r1 = codePara.createRun();

fldChar = r1.getCTR().addNewFldChar();

fldChar.setFldCharType(STFldCharType.BEGIN);

r1 = codePara.createRun();

ctText = r1.getCTR().addNewInstrText();

ctText.setStringValue(\);

ctText.setSpace(SpaceAttribute.Space.PRESERVE);

setParagraphRunFontInfo(codePara, r1, null, \微软雅黑\, \);

fldChar = r1.getCTR().addNewFldChar();

fldChar.setFldCharType(STFldCharType.END);

r1 = codePara.createRun();

r1.setText(\页\);

setParagraphRunFontInfo(codePara, r1, null, \微软雅黑\, \);

setParagraphAlignInfo(codePara, ParagraphAlignment.CENTER,

TextAlignment.CENTER);

codePara.setBorderTop(Borders.THICK);

XWPFParagraph[] newparagraphs = new XWPFParagraph[1];

newparagraphs[0] = codePara;

CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();

XWPFHeaderFooterPolicy headerFooterPolicy = new XWPFHeaderFooterPolicy(

document, sectPr);

headerFooterPolicy.createFooter(STHdrFtr.DEFAULT, newparagraphs);

}

/**

* @Description: 页眉:显示时间信息

*/

public void simpleDateHeader(XWPFDocument document) throws Exception {

CTP ctp = CTP.Factory.newInstance();


poi操作word 2007 常用方法总结(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:我国城乡统筹发展的现状、问题和政策建议

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: