org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge Java Examples

The following examples show how to use org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge. 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: TableTools.java    From poi-tl with Apache License 2.0 6 votes vote down vote up
/**
 * 合并列单元格
 * 
 * @param table
 *            表格对象
 * @param col
 *            列 从0开始
 * @param fromRow
 *            起始行
 * @param toRow
 *            结束行
 */
public static void mergeCellsVertically(XWPFTable table, int col, int fromRow, int toRow) {
    if (toRow <= fromRow) return;
    for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {
        XWPFTableCell cell = table.getRow(rowIndex).getCell(col);
        CTTcPr tcPr = getTcPr(cell);
        CTVMerge vMerge = tcPr.addNewVMerge();
        if (rowIndex == fromRow) {
            // The first merged cell is set with RESTART merge value
            vMerge.setVal(STMerge.RESTART);
        } else {
            // Cells which join (merge) the first one, are set with CONTINUE
            vMerge.setVal(STMerge.CONTINUE);
        }
    }
}
 
Example #2
Source File: WordProducer.java    From ureport with Apache License 2.0 5 votes vote down vote up
private void mergeCellsHorizontal(XWPFTable table, int row, int startCol,int endCol) {
	for (int cellIndex = startCol; cellIndex <= endCol; cellIndex++) {
		XWPFTableCell cell = table.getRow(row).getCell(cellIndex);
		if (cellIndex == startCol) {
			cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);
		} else {
			cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);
		}
	}
}
 
Example #3
Source File: WordProducer.java    From ureport with Apache License 2.0 5 votes vote down vote up
private void mergeCellsVertically(XWPFTable table, int col, int fromRow,int toRow) {
	for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {
		XWPFTableCell cell = table.getRow(rowIndex).getCell(col);
		if (rowIndex == fromRow) {
			cell.getCTTc().addNewTcPr().addNewVMerge()
					.setVal(STMerge.RESTART);
		} else {
			cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
		}
	}
}
 
Example #4
Source File: WordDocxTableParser.java    From SnowGraph with Apache License 2.0 5 votes vote down vote up
private static boolean isVMergeRestart(XWPFTableCell cell) {
    if (cell == null)
        return false;
    CTTcPr tcPr = cell.getCTTc().getTcPr();
    if (tcPr == null || !tcPr.isSetVMerge())
        return false;

    // 如果不判断isVMerge,会getVMerge==null? NullException Alert!
    return (tcPr.getVMerge().getVal() == STMerge.RESTART);
}