Search in sources :

Example 26 with TcPr

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

the class Docx4jUtils method setCellVMerge.

private void setCellVMerge(Tc tableCell, String mergeVal) {
    if (mergeVal != null) {
        TcPr tableCellProperties = tableCell.getTcPr();
        if (tableCellProperties == null) {
            tableCellProperties = new TcPr();
            tableCell.setTcPr(tableCellProperties);
        }
        VMerge merge = new VMerge();
        if (!"close".equals(mergeVal)) {
            merge.setVal(mergeVal);
        }
        tableCellProperties.setVMerge(merge);
    }
}
Also used : TcPr(org.docx4j.wml.TcPr) VMerge(org.docx4j.wml.TcPrInner.VMerge)

Example 27 with TcPr

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

the class Docx4jUtils method setCellNoWrap.

private void setCellNoWrap(Tc tableCell) {
    TcPr tableCellProperties = tableCell.getTcPr();
    if (tableCellProperties == null) {
        tableCellProperties = new TcPr();
        tableCell.setTcPr(tableCellProperties);
    }
    BooleanDefaultTrue b = new BooleanDefaultTrue();
    b.setVal(true);
    tableCellProperties.setNoWrap(b);
}
Also used : TcPr(org.docx4j.wml.TcPr) BooleanDefaultTrue(org.docx4j.wml.BooleanDefaultTrue)

Example 28 with TcPr

use of org.docx4j.wml.TcPr 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);
    }
}
Also used : TcPr(org.docx4j.wml.TcPr) CTVerticalJc(org.docx4j.wml.CTVerticalJc)

Example 29 with TcPr

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

the class NestedTable method addTc.

protected static void addTc(Tr tr, String text) {
    Tc tc = factory.createTc();
    TcPr tcPr = new TcPr();
    TblWidth width = new TblWidth();
    width.setType("dxa");
    width.setW(new BigInteger("3192"));
    tcPr.setTcW(width);
    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 30 with TcPr

use of org.docx4j.wml.TcPr 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);
}
Also used : P(org.docx4j.wml.P) R(org.docx4j.wml.R) TcPr(org.docx4j.wml.TcPr) CTShd(org.docx4j.wml.CTShd) Text(org.docx4j.wml.Text) CTVerticalJc(org.docx4j.wml.CTVerticalJc) Tc(org.docx4j.wml.Tc)

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