Search in sources :

Example 21 with TcPr

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

the class Docx4j_替换模板 method getTcPr.

public static TcPr getTcPr(Tc tc) {
    TcPr tcPr = tc.getTcPr();
    if (tcPr == null) {
        tcPr = new TcPr();
        tc.setTcPr(tcPr);
    }
    return tcPr;
}
Also used : TcPr(org.docx4j.wml.TcPr)

Example 22 with TcPr

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

the class WordprocessingMLPackageRender method addMergedCell.

/**
 *  我们创建一个单元格和单元格属性对象.
 *  也创建了一个纵向合并对象. 如果合并值不为null, 将它设置到合并对象中. 然后将该对象添加到
 *  单元格属性并将属性添加到单元格中. 最后设置单元格内容并将单元格添加到行中.
 *  如果合并值为'restart', 表明要开始一个新行. 如果为null, 继续按前面的行处理, 也就是合并单元格.
 */
public void addMergedCell(Tr row, String content, String vMergeVal) {
    Tc tableCell = factory.createTc();
    TcPr tableCellProperties = new TcPr();
    VMerge merge = new VMerge();
    if (vMergeVal != null) {
        merge.setVal(vMergeVal);
    }
    tableCellProperties.setVMerge(merge);
    tableCell.setTcPr(tableCellProperties);
    if (content != null) {
        tableCell.getContent().add(wmlPackage.getMainDocumentPart().createParagraphOfText(content));
    }
    row.getContent().add(tableCell);
}
Also used : TcPr(org.docx4j.wml.TcPr) Tc(org.docx4j.wml.Tc) VMerge(org.docx4j.wml.TcPrInner.VMerge)

Example 23 with TcPr

use of org.docx4j.wml.TcPr in project TranskribusCore by Transkribus.

the class DocxBuilder method applyGridSpan.

private static void applyGridSpan(final Tc cell, final int colSpan, final String rowSpan, int w, boolean mergedVertical) {
    TcPr tcPr = factory.createTcPr();
    TblWidth tblWidth = factory.createTblWidth();
    tblWidth.setType("dxa");
    tblWidth.setW(BigInteger.valueOf(w * colSpan));
    tcPr.setTcW(tblWidth);
    if (colSpan > 1) {
        GridSpan gridSpan = factory.createTcPrInnerGridSpan();
        gridSpan.setVal(BigInteger.valueOf(colSpan));
        tcPr.setGridSpan(gridSpan);
    }
    if (mergedVertical) {
        // logger.debug(" this is vertical span");
        VMerge gridVSpan = factory.createTcPrInnerVMerge();
        if (rowSpan != null)
            gridVSpan.setVal(rowSpan);
        tcPr.setVMerge(gridVSpan);
    }
    cell.setTcPr(tcPr);
}
Also used : TblWidth(org.docx4j.wml.TblWidth) TcPr(org.docx4j.wml.TcPr) GridSpan(org.docx4j.wml.TcPrInner.GridSpan) VMerge(org.docx4j.wml.TcPrInner.VMerge)

Example 24 with TcPr

use of org.docx4j.wml.TcPr in project Java-Tutorial by gpcodervn.

the class ComplexTable method addTc.

private static void addTc(Tr tr, String label, String text, String width) {
    Tc tc = factory.createTc();
    TcPr tcPr = new TcPr();
    TblWidth tblwidth = new TblWidth();
    tblwidth.setType("dxa");
    tblwidth.setW(new BigInteger(width));
    tcPr.setTcW(tblwidth);
    tc.setTcPr(tcPr);
    tc.getEGBlockLevelElts().add(wordMLPackage.getMainDocumentPart().createParagraphOfText(text));
    tr.getEGContentCellContent().add(tc);
}
Also used : TblWidth(org.docx4j.wml.TblWidth) TcPr(org.docx4j.wml.TcPr) BigInteger(java.math.BigInteger) Tc(org.docx4j.wml.Tc)

Example 25 with TcPr

use of org.docx4j.wml.TcPr in project Java-Tutorial by gpcodervn.

the class Docx4jUtils method setCellBorders.

private void setCellBorders(Tc tableCell, boolean borderTop, boolean borderRight, boolean borderBottom, boolean borderLeft) {
    TcPr tableCellProperties = tableCell.getTcPr();
    if (tableCellProperties == null) {
        tableCellProperties = new TcPr();
        tableCell.setTcPr(tableCellProperties);
    }
    CTBorder border = new CTBorder();
    // border.setColor("auto");
    border.setColor("0000FF");
    border.setSz(new BigInteger("20"));
    border.setSpace(new BigInteger("0"));
    border.setVal(STBorder.SINGLE);
    TcBorders borders = new TcBorders();
    if (borderBottom) {
        borders.setBottom(border);
    }
    if (borderTop) {
        borders.setTop(border);
    }
    if (borderLeft) {
        borders.setLeft(border);
    }
    if (borderRight) {
        borders.setRight(border);
    }
    tableCellProperties.setTcBorders(borders);
}
Also used : TcPr(org.docx4j.wml.TcPr) CTBorder(org.docx4j.wml.CTBorder) BigInteger(java.math.BigInteger) TcBorders(org.docx4j.wml.TcPrInner.TcBorders)

Aggregations

TcPr (org.docx4j.wml.TcPr)46 Tc (org.docx4j.wml.Tc)22 TblWidth (org.docx4j.wml.TblWidth)14 BigInteger (java.math.BigInteger)11 VMerge (org.docx4j.wml.TcPrInner.VMerge)10 GridSpan (org.docx4j.wml.TcPrInner.GridSpan)9 CTVerticalJc (org.docx4j.wml.CTVerticalJc)7 Tr (org.docx4j.wml.Tr)7 CTShd (org.docx4j.wml.CTShd)6 P (org.docx4j.wml.P)5 R (org.docx4j.wml.R)5 Text (org.docx4j.wml.Text)4 Tbl (org.docx4j.wml.Tbl)3 TblPr (org.docx4j.wml.TblPr)3 HMerge (org.docx4j.wml.TcPrInner.HMerge)3 BooleanDefaultTrue (org.docx4j.wml.BooleanDefaultTrue)2 CTBorder (org.docx4j.wml.CTBorder)2 TblStyle (org.docx4j.wml.CTTblPrBase.TblStyle)2 PPr (org.docx4j.wml.PPr)2 TcMar (org.docx4j.wml.TcMar)2