Search in sources :

Example 1 with CTTblCellMar

use of org.docx4j.wml.CTTblCellMar in project docx4j-template by vindell.

the class Docx4j_工具类_S3_Test method setTableCellMargin.

/**
 * @Description: 设置单元格Margin
 */
public void setTableCellMargin(Tbl tbl, String top, String right, String bottom, String left) {
    TblPr tblPr = getTblPr(tbl);
    CTTblCellMar cellMar = tblPr.getTblCellMar();
    if (cellMar == null) {
        cellMar = new CTTblCellMar();
        tblPr.setTblCellMar(cellMar);
    }
    if (StringUtils.isNotBlank(top)) {
        TblWidth topW = new TblWidth();
        topW.setW(new BigInteger(top));
        topW.setType("dxa");
        cellMar.setTop(topW);
    }
    if (StringUtils.isNotBlank(right)) {
        TblWidth rightW = new TblWidth();
        rightW.setW(new BigInteger(right));
        rightW.setType("dxa");
        cellMar.setRight(rightW);
    }
    if (StringUtils.isNotBlank(bottom)) {
        TblWidth btW = new TblWidth();
        btW.setW(new BigInteger(bottom));
        btW.setType("dxa");
        cellMar.setBottom(btW);
    }
    if (StringUtils.isNotBlank(left)) {
        TblWidth leftW = new TblWidth();
        leftW.setW(new BigInteger(left));
        leftW.setType("dxa");
        cellMar.setLeft(leftW);
    }
}
Also used : TblWidth(org.docx4j.wml.TblWidth) BigInteger(java.math.BigInteger) TblPr(org.docx4j.wml.TblPr) CTTblCellMar(org.docx4j.wml.CTTblCellMar)

Aggregations

BigInteger (java.math.BigInteger)1 CTTblCellMar (org.docx4j.wml.CTTblCellMar)1 TblPr (org.docx4j.wml.TblPr)1 TblWidth (org.docx4j.wml.TblWidth)1