use of org.docx4j.wml.CTVerticalJc in project docx4j-template by vindell.
the class Docx4J_例子2 method createNormalCell.
public void createNormalCell(ObjectFactory factory, Tr tr, String content, RPr rpr, JcEnumeration jcEnumeration, boolean hasBgColor, String backgroudColor, boolean isHMerger, String mergeVal) {
Tc tableCell = factory.createTc();
P p = factory.createP();
setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
Text t = factory.createText();
t.setValue(content);
R run = factory.createR();
// 设置表格内容字体样式
run.setRPr(rpr);
TcPr tcPr = tableCell.getTcPr();
if (tcPr == null) {
tcPr = factory.createTcPr();
}
CTVerticalJc valign = factory.createCTVerticalJc();
valign.setVal(STVerticalJc.CENTER);
tcPr.setVAlign(valign);
if (isHMerger) {
HMerge merge = new HMerge();
if (mergeVal != null) {
merge.setVal(mergeVal);
}
tcPr.setHMerge(merge);
} else {
VMerge merge = new VMerge();
if (mergeVal != null) {
merge.setVal(mergeVal);
}
tcPr.setVMerge(merge);
}
run.getContent().add(t);
p.getContent().add(run);
tableCell.getContent().add(p);
if (hasBgColor) {
CTShd shd = tcPr.getShd();
if (shd == null) {
shd = factory.createCTShd();
}
shd.setColor("auto");
shd.setFill(backgroudColor);
tcPr.setShd(shd);
}
tableCell.setTcPr(tcPr);
tr.getContent().add(tableCell);
}
use of org.docx4j.wml.CTVerticalJc in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setDocVAlign.
/**
* @Description:设置word 垂直对齐方式(Word默认方式都是"顶端对齐")
*/
public void setDocVAlign(WordprocessingMLPackage wordPackage, STVerticalJc valignType) {
if (valignType != null) {
SectPr sectPr = getDocSectPr(wordPackage);
CTVerticalJc valign = sectPr.getVAlign();
if (valign == null) {
valign = new CTVerticalJc();
sectPr.setVAlign(valign);
}
valign.setVal(valignType);
}
}
use of org.docx4j.wml.CTVerticalJc in project docx4j-template by vindell.
the class Docx4j_工具类_S3_Test method setTcVAlign.
/**
* @Description: 设置单元格垂直对齐方式
*/
public void setTcVAlign(Tc tc, STVerticalJc vAlignType) {
if (vAlignType != null) {
TcPr tcPr = getTcPr(tc);
CTVerticalJc vAlign = new CTVerticalJc();
vAlign.setVal(vAlignType);
tcPr.setVAlign(vAlign);
}
}
use of org.docx4j.wml.CTVerticalJc in project Java-Tutorial by gpcodervn.
the class Docx4jUtils method setVerticalAlignment.
private void setVerticalAlignment(Tc tableCell, STVerticalJc align) {
if (align != null) {
TcPr tableCellProperties = tableCell.getTcPr();
if (tableCellProperties == null) {
tableCellProperties = new TcPr();
tableCell.setTcPr(tableCellProperties);
}
CTVerticalJc valign = new CTVerticalJc();
valign.setVal(align);
tableCellProperties.setVAlign(valign);
}
}
use of org.docx4j.wml.CTVerticalJc in project docx4j-template by vindell.
the class Docx4J_例子2 method addTableCell.
// 新增单元格
public void addTableCell(ObjectFactory factory, WordprocessingMLPackage wordMLPackage, Tr tableRow, String content, RPr rpr, JcEnumeration jcEnumeration, boolean hasBgColor, String backgroudColor) {
Tc tableCell = factory.createTc();
P p = factory.createP();
setParagraphSpacing(factory, p, jcEnumeration, true, "0", "0", null, null, true, "240", STLineSpacingRule.AUTO);
Text t = factory.createText();
t.setValue(content);
R run = factory.createR();
// 设置表格内容字体样式
run.setRPr(rpr);
TcPr tcPr = tableCell.getTcPr();
if (tcPr == null) {
tcPr = factory.createTcPr();
}
CTVerticalJc valign = factory.createCTVerticalJc();
valign.setVal(STVerticalJc.CENTER);
tcPr.setVAlign(valign);
run.getContent().add(t);
p.getContent().add(run);
tableCell.getContent().add(p);
if (hasBgColor) {
CTShd shd = tcPr.getShd();
if (shd == null) {
shd = factory.createCTShd();
}
shd.setColor("auto");
shd.setFill(backgroudColor);
tcPr.setShd(shd);
}
tableCell.setTcPr(tcPr);
tableRow.getContent().add(tableCell);
}
Aggregations