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

2019-03-29 13:04

hightLight.setVal(hightStyle);

}

}

if (isShd) {

// 设置底纹

CTShd shd = pRpr.isSetShd() ? pRpr.getShd() : pRpr.addNewShd();

if (shdStyle != null) {

shd.setVal(shdStyle);

}

if (shdColor != null) {

shd.setColor(shdColor);

}

}

// 上标下标

if (verticalAlign != null) {

pRun.setSubscript(verticalAlign);

}

// 设置文本位置

pRun.setTextPosition(position);

if (spacingValue > 0) {

// 设置字符间距信息

CTSignedTwipsMeasure ctSTwipsMeasure = pRpr.isSetSpacing() ? pRpr

.getSpacing() : pRpr.addNewSpacing();

ctSTwipsMeasure

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

}

if (indent > 0) {

CTTextScale paramCTTextScale = pRpr.isSetW() ? pRpr.getW() : pRpr

.addNewW();

paramCTTextScale.setVal(indent);

}

}

/**

* @Description: 设置段落底纹(对整段文字起作用)

*/

public void setParagraphShdStyle(XWPFParagraph p, boolean isShd,

STShd.Enum shdStyle, String shdColor) {

CTPPr pPpr = getParagraphCTPPr(p);

CTShd shd = pPpr.isSetShd() ? pPpr.getShd() : pPpr.addNewShd();

if (shdStyle != null) {

shd.setVal(shdStyle);

}

if (shdColor != null) {

shd.setColor(shdColor);

}

}

/**

* @Description: 设置段落间距信息,一行=100 一磅=20

*/

public void setParagraphSpacingInfo(XWPFParagraph p, boolean isSpace,

String before, String after, String beforeLines, String afterLines,

boolean isLine, String line, STLineSpacingRule.Enum lineValue) {

CTPPr pPPr = getParagraphCTPPr(p);

CTSpacing pSpacing = pPPr.getSpacing() != null ? pPPr.getSpacing()

: pPPr.addNewSpacing();

if (isSpace) {

// 段前磅数

if (before != null) {

pSpacing.setBefore(new BigInteger(before));

}

// 段后磅数

if (after != null) {

pSpacing.setAfter(new BigInteger(after));

}

// 段前行数

if (beforeLines != null) {

pSpacing.setBeforeLines(new BigInteger(beforeLines));

}

// 段后行数

if (afterLines != null) {

pSpacing.setAfterLines(new BigInteger(afterLines));

}

}

// 间距

if (isLine) {

if (line != null) {

pSpacing.setLine(new BigInteger(line));

}

if (lineValue != null) {

pSpacing.setLineRule(lineValue);

}

}

}

// 设置段落缩进信息 1厘米≈567

public void setParagraphIndInfo(XWPFParagraph p, String firstLine,

String firstLineChar, String hanging, String hangingChar,

String right, String rigthChar, String left, String leftChar) {

CTPPr pPPr = getParagraphCTPPr(p);

CTInd pInd = pPPr.getInd() != null ? pPPr.getInd() : pPPr.addNewInd();

if (firstLine != null) {

pInd.setFirstLine(new BigInteger(firstLine));

}


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

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

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

马上注册会员

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