Search in sources :

Example 6 with TblPr

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

the class Docx4J_简单例子2 method setTableAlign.

// 表格水平对齐方式
public void setTableAlign(ObjectFactory factory, Tbl table, JcEnumeration jcEnumeration) {
    TblPr tablePr = table.getTblPr();
    if (tablePr == null) {
        tablePr = factory.createTblPr();
    }
    Jc jc = tablePr.getJc();
    if (jc == null) {
        jc = new Jc();
    }
    jc.setVal(jcEnumeration);
    tablePr.setJc(jc);
    table.setTblPr(tablePr);
}
Also used : STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) TblPr(org.docx4j.wml.TblPr)

Example 7 with TblPr

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

the class Docx4j_工具类_S3_Test method setTblJcAlign.

/**
 * @Description: 设置表格水平对齐方式(仅对表格起作用,单元格不一定水平对齐)
 */
public void setTblJcAlign(Tbl tbl, JcEnumeration jcType) {
    if (jcType != null) {
        TblPr tblPr = getTblPr(tbl);
        Jc jc = tblPr.getJc();
        if (jc == null) {
            jc = new Jc();
            tblPr.setJc(jc);
        }
        jc.setVal(jcType);
    }
}
Also used : STVerticalJc(org.docx4j.wml.STVerticalJc) Jc(org.docx4j.wml.Jc) CTVerticalJc(org.docx4j.wml.CTVerticalJc) TblPr(org.docx4j.wml.TblPr)

Example 8 with TblPr

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

the class Docx4j_工具类_S3_Test method setTableWidth.

/**
 * @Description: 设置表格总宽度
 */
public void setTableWidth(Tbl tbl, String width) {
    if (StringUtils.isNotBlank(width)) {
        TblPr tblPr = getTblPr(tbl);
        TblWidth tblW = tblPr.getTblW();
        if (tblW == null) {
            tblW = new TblWidth();
            tblPr.setTblW(tblW);
        }
        tblW.setW(new BigInteger(width));
        tblW.setType("dxa");
    }
}
Also used : TblWidth(org.docx4j.wml.TblWidth) BigInteger(java.math.BigInteger) TblPr(org.docx4j.wml.TblPr)

Example 9 with TblPr

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

the class SettingColumnWidthForTable method addBorders.

/**
 *  本方法为表格添加边框
 */
private static void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger("4"));
    border.setSpace(new BigInteger("0"));
    border.setVal(STBorder.SINGLE);
    TblBorders borders = new TblBorders();
    borders.setBottom(border);
    borders.setLeft(border);
    borders.setRight(border);
    borders.setTop(border);
    borders.setInsideH(border);
    borders.setInsideV(border);
    table.getTblPr().setTblBorders(borders);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Example 10 with TblPr

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

the class TableWithMergedCells method addBorders.

/**
 *  本方法为表格添加边框
 */
private static void addBorders(Tbl table) {
    table.setTblPr(new TblPr());
    CTBorder border = new CTBorder();
    border.setColor("auto");
    border.setSz(new BigInteger("4"));
    border.setSpace(new BigInteger("0"));
    border.setVal(STBorder.SINGLE);
    TblBorders borders = new TblBorders();
    borders.setBottom(border);
    borders.setLeft(border);
    borders.setRight(border);
    borders.setTop(border);
    borders.setInsideH(border);
    borders.setInsideV(border);
    table.getTblPr().setTblBorders(borders);
}
Also used : CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TblBorders(org.docx4j.wml.TblBorders) TblPr(org.docx4j.wml.TblPr)

Aggregations

TblPr (org.docx4j.wml.TblPr)26 BigInteger (java.math.BigInteger)14 TblBorders (org.docx4j.wml.TblBorders)10 CTBorder (org.docx4j.wml.CTBorder)9 TblWidth (org.docx4j.wml.TblWidth)8 Tbl (org.docx4j.wml.Tbl)7 Tr (org.docx4j.wml.Tr)7 Jc (org.docx4j.wml.Jc)5 Tc (org.docx4j.wml.Tc)5 TblStyle (org.docx4j.wml.CTTblPrBase.TblStyle)4 CTVerticalJc (org.docx4j.wml.CTVerticalJc)4 P (org.docx4j.wml.P)4 STVerticalJc (org.docx4j.wml.STVerticalJc)4 TblGrid (org.docx4j.wml.TblGrid)3 TblGridCol (org.docx4j.wml.TblGridCol)3 TcPr (org.docx4j.wml.TcPr)3 File (java.io.File)2 STHint (org.docx4j.wml.STHint)2 TrPr (org.docx4j.wml.TrPr)2 FileNotFoundException (java.io.FileNotFoundException)1