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();
setParagraphAlign(factory, p, jcEnumeration);
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);
PPr ppr = p.getPPr();
if (ppr == null) {
ppr = factory.createPPr();
}
// 设置段后距离
Spacing spacing = new Spacing();
spacing.setAfter(new BigInteger("0"));
spacing.setLineRule(STLineSpacingRule.AUTO);
ppr.setSpacing(spacing);
p.setPPr(ppr);
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);
}
use of org.docx4j.wml.CTVerticalJc in project docx4j-template by vindell.
the class Docx4jStyle_S3 method setVerticalAlignment.
public 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);
}
}
Aggregations