Search in sources :

Example 41 with Tc

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

the class WordprocessingMLPackageRender method addTableCell.

public void addTableCell(Tr tableRow, String content) {
    Tc tableCell = factory.createTc();
    tableCell.getContent().add(wmlPackage.getMainDocumentPart().createParagraphOfText(content));
    tableRow.getContent().add(tableCell);
}
Also used : Tc(org.docx4j.wml.Tc)

Example 42 with Tc

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

the class WordprocessingMLPackageRender method addStyledTableCell.

/**
 *  本方法创建单元格, 添加样式后添加到表格行中
 */
public void addStyledTableCell(Tr tableRow, String content, boolean bold, String fontSize) {
    Tc tableCell = factory.createTc();
    addStyling(tableCell, content, bold, fontSize);
    tableRow.getContent().add(tableCell);
}
Also used : Tc(org.docx4j.wml.Tc)

Example 43 with Tc

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

the class AddingAnInlineImageToTable method addTableCell.

/**
 * 用给定的段落作为内容向给定的行中添加一个单元格.
 *
 * @param tr
 * @param paragraph
 */
private static void addTableCell(Tr tr, P paragraph) {
    Tc tc1 = factory.createTc();
    tc1.getContent().add(paragraph);
    tr.getContent().add(tc1);
}
Also used : Tc(org.docx4j.wml.Tc)

Example 44 with Tc

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

the class WmlElementUtils method getTcByPosition.

/*
     * http://53873039oycg.iteye.com/blog/2194849
     *  实现思路:
        主要分在当前行上方插入行和在当前行下方插入行。对首尾2行特殊处理,在有跨行合并情况时,在第一行上面或者在最后一行下面插入是不会跨行的但是可能会跨列。
       对于中间的行,主要参照当前行,如果当前行跨行,则新增行也跨行,如果当前行单元格结束跨行,则新增的上方插入行跨行,下方插入行不跨行,如果当前行单元格开始跨行,则新增的上方插入行不跨行,下发插入行跨行。
       主要思路就是这样,插入的时候需要得到真实位置的单元格,代码如下:
       
     */
// 按位置得到单元格(考虑跨列合并情况)
public Tc getTcByPosition(List<Tc> tcList, int position) {
    int k = 0;
    for (int i = 0, len = tcList.size(); i < len; i++) {
        Tc tc = tcList.get(i);
        TcPr trPr = tc.getTcPr();
        if (trPr != null) {
            GridSpan gridSpan = trPr.getGridSpan();
            if (gridSpan != null) {
                k += gridSpan.getVal().intValue() - 1;
            }
        }
        if (k >= position) {
            return tcList.get(i);
        }
        k++;
    }
    if (position < tcList.size()) {
        return tcList.get(position);
    }
    return null;
}
Also used : TcPr(org.docx4j.wml.TcPr) Tc(org.docx4j.wml.Tc) GridSpan(org.docx4j.wml.TcPrInner.GridSpan)

Example 45 with Tc

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

the class DocxElementWmlRender method newCell.

public Tc newCell(Tr tableRow, String content) {
    Tc tbCell = factory.createTc();
    tbCell.getContent().add(newParagraph(content));
    tbCell.getContent().add(tbCell);
    return tbCell;
}
Also used : Tc(org.docx4j.wml.Tc)

Aggregations

Tc (org.docx4j.wml.Tc)53 TcPr (org.docx4j.wml.TcPr)22 Tr (org.docx4j.wml.Tr)17 P (org.docx4j.wml.P)11 R (org.docx4j.wml.R)10 Tbl (org.docx4j.wml.Tbl)9 BigInteger (java.math.BigInteger)7 TblWidth (org.docx4j.wml.TblWidth)7 VMerge (org.docx4j.wml.TcPrInner.VMerge)7 Text (org.docx4j.wml.Text)7 GridSpan (org.docx4j.wml.TcPrInner.GridSpan)6 CTVerticalJc (org.docx4j.wml.CTVerticalJc)5 TblPr (org.docx4j.wml.TblPr)5 ArrayList (java.util.ArrayList)4 CTShd (org.docx4j.wml.CTShd)4 File (java.io.File)3 WordprocessingMLPackage (org.docx4j.openpackaging.packages.WordprocessingMLPackage)3 MainDocumentPart (org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart)3 ObjectFactory (org.docx4j.wml.ObjectFactory)3 PPr (org.docx4j.wml.PPr)3