org.docx4j.wml.Tc Java Examples

The following examples show how to use org.docx4j.wml.Tc. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableWithMergedCells.java    From docx4j-template with Apache License 2.0 8 votes vote down vote up
/**
 *  我们创建一个单元格和单元格属性对象.
 *  也创建了一个纵向合并对象. 如果合并值不为null, 将它设置到合并对象中. 然后将该对象添加到
 *  单元格属性并将属性添加到单元格中. 最后设置单元格内容并将单元格添加到行中.
 *  
 *  如果合并值为'restart', 表明要开始一个新行. 如果为null, 继续按前面的行处理, 也就是合并单元格.
 */
private static 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(
            wordMLPackage.getMainDocumentPart().
                createParagraphOfText(content));
    }
 
    row.getContent().add(tableCell);
}
 
Example #2
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 跨列合并
 */
public static void mergeCellsHorizontalByGridSpan(Tbl tbl, int row, int fromCell, int toCell) {
    if (row < 0 || fromCell < 0 || toCell < 0) {
        return;
    }
    List<Tr> trList = getTblAllTr(tbl);
    if (row > trList.size()) {
        return;
    }
    Tr tr = trList.get(row);
    List<Tc> tcList = getTrAllCell(tr);
    for (int cellIndex = Math.min(tcList.size() - 1, toCell); cellIndex >= fromCell; cellIndex--) {
        Tc tc = tcList.get(cellIndex);
        TcPr tcPr = getTcPr(tc);
        if (cellIndex == fromCell) {
            GridSpan gridSpan = tcPr.getGridSpan();
            if (gridSpan == null) {
                gridSpan = new GridSpan();
                tcPr.setGridSpan(gridSpan);
            }
            gridSpan.setVal(BigInteger.valueOf(Math.min(tcList.size() - 1, toCell) - fromCell + 1));
        } else {
            tr.getContent().remove(cellIndex);
        }
    }
}
 
Example #3
Source File: Docx4j_合并单元格_S4_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/** 
 * @Description: 跨行合并 
 */  
public void mergeCellsVertically(Tbl tbl, int col, int fromRow, int toRow) {  
    if (col < 0 || fromRow < 0 || toRow < 0) {  
        return;  
    }  
    for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {  
        Tc tc = getTc(tbl, rowIndex, col);  
        if (tc == null) {  
            break;  
        }  
        TcPr tcPr = getTcPr(tc);  
        VMerge vMerge = tcPr.getVMerge();  
        if (vMerge == null) {  
            vMerge = new VMerge();  
            tcPr.setVMerge(vMerge);  
        }  
        if (rowIndex == fromRow) {  
            vMerge.setVal("restart");  
        } else {  
            vMerge.setVal("continue");  
        }  
    }  
}
 
Example #4
Source File: Docx4j_替换模板.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/** 
 * @Description: 跨行合并 
 */  
public static void mergeCellsVertically(Tbl tbl, int col, int fromRow, int toRow) {  
    if (col < 0 || fromRow < 0 || toRow < 0) {  
        return;  
    }  
    for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {  
        Tc tc = getTc(tbl, rowIndex, col);  
        if (tc == null) {  
            break;  
        }  
        TcPr tcPr = getTcPr(tc);  
        VMerge vMerge = tcPr.getVMerge();  
        if (vMerge == null) {  
            vMerge = factory.createTcPrInnerVMerge();  
            tcPr.setVMerge(vMerge);  
        }  
        if (rowIndex == fromRow) {  
            vMerge.setVal("restart");  
        } else {  
            vMerge.setVal("continue");  
        }  
    }  
}
 
Example #5
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 跨行合并
 */
public void mergeCellsVertically(Tbl tbl, int col, int fromRow, int toRow) {
    if (col < 0 || fromRow < 0 || toRow < 0) {
        return;
    }
    for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {
        Tc tc = getTc(tbl, rowIndex, col);
        if (tc == null) {
            break;
        }
        TcPr tcPr = getTcPr(tc);
        VMerge vMerge = tcPr.getVMerge();
        if (vMerge == null) {
            vMerge = new VMerge();
            tcPr.setVMerge(vMerge);
        }
        if (rowIndex == fromRow) {
            vMerge.setVal("restart");
        } else {
            vMerge.setVal("continue");
        }
    }
}
 
Example #6
Source File: ConditionalDisplayOfParagraphsTest.java    From docx-stamper with MIT License 6 votes vote down vote up
private void paragraphsInNestedTablesAreRemoved(WordprocessingMLPackage document) {
    final List<Tbl> tables = new ArrayList<>();
    CoordinatesWalker walker = new BaseCoordinatesWalker(document) {
        @Override
        protected void onTable(TableCoordinates tableCoordinates) {
            tables.add(tableCoordinates.getTable());
        }
    };
    walker.walk();

    Tbl nestedTable = tables.get(1);
    Tc cell = (Tc) ((JAXBElement) ((Tr) nestedTable.getContent().get(1)).getContent().get(0)).getValue();
    P p1 = (P) cell.getContent().get(0);

    Assert.assertEquals(1, cell.getContent().size());
    Assert.assertEquals("This paragraph stays untouched.", new ParagraphWrapper(p1).getText());
}
 
Example #7
Source File: Docx4j_替换模板.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/** 
 * 设置单元格内容 
 *  
 * @param tc 
 * @param content 
 */  
public static void setNewTcContent(Tc tc, String content) {  
    P p = factory.createP();  
    tc.getContent().add(p);  
    R run = factory.createR();  
    p.getContent().add(run);  
    if (content != null) {  
        String[] contentArr = content.split("\n");  
        Text text = factory.createText();  
        text.setSpace("preserve");  
        text.setValue(contentArr[0]);  
        run.getContent().add(text);  
  
        for (int i = 1, len = contentArr.length; i < len; i++) {  
            Br br = factory.createBr();  
            run.getContent().add(br);// 换行  
            text = factory.createText();  
            text.setSpace("preserve");  
            text.setValue(contentArr[i]);  
            run.getContent().add(text);  
        }  
    }  
}
 
Example #8
Source File: TableWithStyledContent.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 *  这里我们添加实际的样式信息, 首先创建一个段落, 然后创建以单元格内容作为值的文本对象; 
 *  第三步, 创建一个被称为运行块的对象, 它是一块或多块拥有共同属性的文本的容器, 并将文本对象添加
 *  到其中. 随后我们将运行块R添加到段落内容中.
 *  直到现在我们所做的还没有添加任何样式, 为了达到目标, 我们创建运行块属性对象并给它添加各种样式.
 *  这些运行块的属性随后被添加到运行块. 最后段落被添加到表格的单元格中.
 */
private static void addStyling(Tc tableCell, String content, boolean bold, String fontSize) {
    P paragraph = factory.createP();
 
    Text text = factory.createText();
    text.setValue(content);
 
    R run = factory.createR();
    run.getContent().add(text);
 
    paragraph.getContent().add(run);
 
    RPr runProperties = factory.createRPr();
    if (bold) {
        addBoldStyle(runProperties);
    }
 
    if (fontSize != null && !fontSize.isEmpty()) {
        setFontSize(runProperties, fontSize);
    }
 
    run.setRPr(runProperties);
 
    tableCell.getContent().add(paragraph);
}
 
Example #9
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 隐藏单元格内容
 */
public static void setTcHidden(Tc tc, boolean hidden) {
    List<P> pList = getTcAllP(tc);
    for (P p : pList) {
        PPr ppr = getPPr(p);
        List<Object> objRList = getAllElementFromObject(p, R.class);
        if (objRList == null) {
            continue;
        }
        for (Object objR : objRList) {
            if (objR instanceof R) {
                R r = (R) objR;
                RPr rpr = getRPr(r);
                setRPrVanishStyle(rpr, hidden);
            }
        }
        setParaVanish(ppr, hidden);
    }
}
 
Example #10
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 *   实现思路:
     主要分在当前行上方插入行和在当前行下方插入行。对首尾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;  
}
 
Example #11
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 得到行的列数
 */
public static int getTcCellSizeWithMergeNum(Tr tr) {
    int cellSize = 1;
    List<Tc> tcList = getTrAllCell(tr);
    if (tcList == null || tcList.size() == 0) {
        return cellSize;
    }
    cellSize = tcList.size();
    for (Tc tc : tcList) {
        TcPr tcPr = getTcPr(tc);
        GridSpan gridSpan = tcPr.getGridSpan();
        if (gridSpan != null) {
            cellSize += gridSpan.getVal().intValue() - 1;
        }
    }
    return cellSize;
}
 
Example #12
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 得到行的列数
 */
public int getTcCellSizeWithMergeNum(Tr tr) {
    int cellSize = 1;
    List<Tc> tcList = getTrAllCell(tr);
    if (tcList == null || tcList.size() == 0) {
        return cellSize;
    }
    cellSize = tcList.size();
    for (Tc tc : tcList) {
        TcPr tcPr = getTcPr(tc);
        GridSpan gridSpan = tcPr.getGridSpan();
        if (gridSpan != null) {
            cellSize += gridSpan.getVal().intValue() - 1;
        }
    }
    return cellSize;
}
 
Example #13
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 隐藏单元格内容
 */
public void setTcHidden(Tc tc, boolean hidden) {
    List<P> pList = getTcAllP(tc);
    for (P p : pList) {
        PPr ppr = getPPr(p);
        List<Object> objRList = getAllElementFromObject(p, R.class);
        if (objRList == null) {
            continue;
        }
        for (Object objR : objRList) {
            if (objR instanceof R) {
                R r = (R) objR;
                RPr rpr = getRPr(r);
                setRPrVanishStyle(rpr, hidden);
            }
        }
        setParaVanish(ppr, hidden);
    }
}
 
Example #14
Source File: DocxBuilder.java    From TranskribusCore with GNU General Public License v3.0 6 votes vote down vote up
private 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);
}
 
Example #15
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
/**
 * @Description: 跨行合并
 */
public static void mergeCellsVertically(Tbl tbl, int col, int fromRow, int toRow) {
    if (col < 0 || fromRow < 0 || toRow < 0) {
        return;
    }
    for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {
        Tc tc = getTc(tbl, rowIndex, col);
        if (tc == null) {
            break;
        }
        TcPr tcPr = getTcPr(tc);
        VMerge vMerge = tcPr.getVMerge();
        if (vMerge == null) {
            vMerge = new VMerge();
            tcPr.setVMerge(vMerge);
        }
        if (rowIndex == fromRow) {
            vMerge.setVal("restart");
        } else {
            vMerge.setVal("continue");
        }
    }
}
 
Example #16
Source File: WmlElementUtils.java    From docx4j-template with Apache License 2.0 6 votes vote down vote up
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;  
}
 
Example #17
Source File: Docx4J_简单例子.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
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();
	setParagraphAlign(factory, p, jcEnumeration);
	Text t = factory.createText();
	t.setValue(content);
	R run = factory.createR();
	// 设置表格内容字体样式
	run.setRPr(rpr);
	run.getContent().add(t);
	p.getContent().add(run);
	tableCell.getContent().add(p);

	if (hasBgColor) {
		TcPr tcPr = tableCell.getTcPr();
		if (tcPr == null) {
			tcPr = factory.createTcPr();
		}
		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);
}
 
Example #18
Source File: Docx4j_创建表格_S5_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void addTableCell(ObjectFactory factory, Tr tableRow,  
        String content, int width, Docx4jStyle_S3 style,  
        int horizontalMergedCells, String verticalMergedVal) {  
    Tc tableCell = factory.createTc();  
    addCellStyle(factory, tableCell, content, style);  
    setCellWidth(tableCell, width);  
    setCellVMerge(tableCell, verticalMergedVal);  
    setCellHMerge(tableCell, horizontalMergedCells);  
    if (style.isNoWrap()) {  
        setCellNoWrap(tableCell);  
    }  
    tableRow.getContent().add(tableCell);  
}
 
Example #19
Source File: Docx4j_创建表格_S5_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void addTableCell(ObjectFactory factory, Tr tableRow, P image,  
        int width, Docx4jStyle_S3 style, int horizontalMergedCells,  
        String verticalMergedVal) {  
    Tc tableCell = factory.createTc();  
    addImageCellStyle(tableCell, image, style);  
    setCellWidth(tableCell, width);  
    setCellVMerge(tableCell, verticalMergedVal);  
    setCellHMerge(tableCell, horizontalMergedCells);  
    tableRow.getContent().add(tableCell);  
}
 
Example #20
Source File: TableWithBorders.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
private static void addTableCell(Tr tableRow, String content) {
    Tc tableCell = factory.createTc();
    tableCell.getContent().add(
    wordMLPackage.getMainDocumentPart().
        createParagraphOfText(content));
    tableRow.getContent().add(tableCell);
}
 
Example #21
Source File: Docx4j_创建表格_S5_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void addCellStyle(ObjectFactory factory, Tc tableCell,  
        String content, Docx4jStyle_S3 style) {  
    if (style != null) {  
        P paragraph = factory.createP();  
        Text text = factory.createText();  
        text.setValue(content);  
        R run = factory.createR();  
        run.getContent().add(text);  
        paragraph.getContent().add(run);  
        setHorizontalAlignment(paragraph, style.getHorizAlignment());  
        RPr runProperties = factory.createRPr();  
        if (style.isBold()) {  
            addBoldStyle(runProperties);  
        }  
        if (style.isItalic()) {  
            addItalicStyle(runProperties);  
        }  
        if (style.isUnderline()) {  
            addUnderlineStyle(runProperties);  
        }  
        setFontSize(runProperties, style.getFontSize());  
        setFontColor(runProperties, style.getFontColor());  
        setFontFamily(runProperties, style.getCnFontFamily(),style.getEnFontFamily());  
        setCellMargins(tableCell, style.getTop(), style.getRight(),  
                style.getBottom(), style.getLeft());  
        setCellColor(tableCell, style.getBackground());  
        setVerticalAlignment(tableCell, style.getVerticalAlignment());  
        setCellBorders(tableCell, style.isBorderTop(),  
                style.isBorderRight(), style.isBorderBottom(),  
                style.isBorderLeft());  
        run.setRPr(runProperties);  
        tableCell.getContent().add(paragraph);  
    }  
}
 
Example #22
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置单元格垂直对齐方式
 */
public void setTcVAlign(Tc tc, STVerticalJc vAlignType) {
    if (vAlignType != null) {
        TcPr tcPr = getTcPr(tc);
        CTVerticalJc vAlign = new CTVerticalJc();
        vAlign.setVal(vAlignType);
        tcPr.setVAlign(vAlign);
    }
}
 
Example #23
Source File: Docx4j_合并单元格_S4_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public void mergeCellsHorizontalByGridSpan(Tbl tbl, int row, int fromCell,  
        int toCell) {  
    if (row < 0 || fromCell < 0 || toCell < 0) {  
        return;  
    }  
    List<Tr> trList = getTblAllTr(tbl);  
    if (row > trList.size()) {  
        return;  
    }  
    Tr tr = trList.get(row);  
    List<Tc> tcList = getTrAllCell(tr);  
    for (int cellIndex = Math.min(tcList.size() - 1, toCell); cellIndex >= fromCell; cellIndex--) {  
        Tc tc = tcList.get(cellIndex);  
        TcPr tcPr = getTcPr(tc);  
        if (cellIndex == fromCell) {  
            GridSpan gridSpan = tcPr.getGridSpan();  
            if (gridSpan == null) {  
                gridSpan = new GridSpan();  
                tcPr.setGridSpan(gridSpan);  
            }  
            gridSpan.setVal(BigInteger.valueOf(Math.min(tcList.size() - 1,  
                    toCell) - fromCell + 1));  
        } else {  
            tr.getContent().remove(cellIndex);  
        }  
    }  
}
 
Example #24
Source File: Docx4j_替换模板.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public static List<Tc> getTrAllCell(Tr tr) {  
    List<Object> objList = getAllElementFromObject(tr, Tc.class);  
    List<Tc> tcList = new ArrayList<Tc>();  
    if (objList == null) {  
        return tcList;  
    }  
    for (Object tcObj : objList) {  
        if (tcObj instanceof Tc) {  
            Tc objTc = (Tc) tcObj;  
            tcList.add(objTc);  
        }  
    }  
    return tcList;  
}
 
Example #25
Source File: Docx4j_替换模板.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public static Tc getTc(Tbl tbl, int row, int cell) {  
    if (row < 0 || cell < 0) {  
        return null;  
    }  
    List<Tr> trList = getTblAllTr(tbl);  
    if (row >= trList.size()) {  
        return null;  
    }  
    List<Tc> tcList = getTrAllCell(trList.get(row));  
    if (cell >= tcList.size()) {  
        return null;  
    }  
    return tcList.get(cell);  
}
 
Example #26
Source File: ObjectDeleter.java    From docx-stamper with MIT License 5 votes vote down vote up
public void deleteParagraph(ParagraphCoordinates paragraphCoordinates) {
    if (paragraphCoordinates.getParentTableCellCoordinates() == null) {
        // global paragraph
        int indexToDelete = paragraphCoordinates.getIndex() - objectsDeletedFromMainDocument;
        document.getMainDocumentPart().getContent().remove(indexToDelete);
        objectsDeletedFromMainDocument++;
    } else {
        // paragraph within a table cell
        Tc parentCell = paragraphCoordinates.getParentTableCellCoordinates().getCell();
        deleteFromCell(parentCell, paragraphCoordinates.getIndex());
    }
}
 
Example #27
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 设置单元格水平对齐方式
 */
public void setTcJcAlign(Tc tc, JcEnumeration jcType) {
    if (jcType != null) {
        List<P> pList = getTcAllP(tc);
        for (P p : pList) {
            setParaJcAlign(p, jcType);
        }
    }
}
 
Example #28
Source File: Docx4j_替换模板.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/** 
 * 替换单元格内容 
 */  
private void replaceTcContent(Tc tc, String value) {  
    List<Object> rtnList = getAllElementFromObject(tc, Text.class);  
    if (rtnList == null || rtnList.size() == 0) {  
        return;  
    }  
    Text textElement = (Text) rtnList.get(0);  
    textElement.setValue(value);  
}
 
Example #29
Source File: Docx4j_替换模板.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/** 
 * 替换tr数据 
 */  
private void replaceTrSexData(Tr tr, String[] dataArr) throws Exception {  
    List<Tc> tcList = getTrAllCell(tr);  
    Tc tc = null;  
    for (int i = 2, iLen = tcList.size(); i < iLen; i++) {  
        tc = tcList.get(i);  
        replaceTcContent(tc, dataArr[i - 2]);  
    }  
}
 
Example #30
Source File: Docx4j_工具类_S3_Test.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
/**
 * @Description: 获取所有的单元格
 */
public List<Tc> getTrAllCell(Tr tr) {
    List<Object> objList = getAllElementFromObject(tr, Tc.class);
    List<Tc> tcList = new ArrayList<Tc>();
    if (objList == null) {
        return tcList;
    }
    for (Object tcObj : objList) {
        if (tcObj instanceof Tc) {
            Tc objTc = (Tc) tcObj;
            tcList.add(objTc);
        }
    }
    return tcList;
}