发布时间 : 星期日 文章poi操作word 2007 常用方法总结更新完毕开始阅读6fdb6131fe4733687f21aa46
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();