当前位置: 首页>>代码示例>>Java>>正文


Java XWPFTableCell类代码示例

本文整理汇总了Java中org.apache.poi.xwpf.usermodel.XWPFTableCell的典型用法代码示例。如果您正苦于以下问题:Java XWPFTableCell类的具体用法?Java XWPFTableCell怎么用?Java XWPFTableCell使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XWPFTableCell类属于org.apache.poi.xwpf.usermodel包,在下文中一共展示了XWPFTableCell类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCellBorder

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
private void buildCellBorder(Border border, XWPFTableCell tableCell,int type) {
	CTTcPr cellPropertie = tableCell.getCTTc().getTcPr();
	if(cellPropertie==null){
		cellPropertie=tableCell.getCTTc().addNewTcPr();
	}
	CTTcBorders borders=cellPropertie.getTcBorders();
	if(borders==null){
		borders=cellPropertie.addNewTcBorders();;
	}
	BorderStyle borderStyle=border.getStyle();
	CTBorder ctborder=null;
	if(type==1){
		ctborder=borders.addNewLeft();
	}else if(type==2){
		ctborder=borders.addNewRight();
	}else if(type==3){
		ctborder=borders.addNewTop();
	}else if(type==4){
		ctborder=borders.addNewBottom();
	}
	if(borderStyle.equals(BorderStyle.dashed)){
		ctborder.setVal(STBorder.DASHED);
	}else if(borderStyle.equals(BorderStyle.doublesolid)){
		ctborder.setVal(STBorder.DOUBLE);
	}else{
		ctborder.setVal(STBorder.SINGLE);				
	}
	int borderWidth=border.getWidth();
	if(borderWidth>1){
		ctborder.setSz(BigInteger.valueOf(DxaUtils.points2dxa(borderWidth)));				
	}
	String color=border.getColor();
	if(StringUtils.isNotBlank(color)){
		ctborder.setColor(toHex(color.split(",")));
	}
}
 
开发者ID:youseries,项目名称:ureport,代码行数:37,代码来源:WordProducer.java

示例2: spanCellsAcrossRow

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * 테이블의 특정 로우의 컬럼에 해당하는 부분의 셀을 나눔. 나누기는 하나.. 컬럼의 셀수가 일치하지 않고 틀어짐.
 *
 * @param table
 * @param rowNum
 * @param colNum
 * @param span
 */
private static void spanCellsAcrossRow(XWPFTable table, int rowNum, int colNum, int span) {
	XWPFTableRow row = table.getRow(rowNum);
	XWPFTableCell cell = row.getCell(colNum);

	CTDecimalNumber grdSpan = cell.getCTTc().getTcPr().getGridSpan();
	if (grdSpan == null) {
		grdSpan = cell.getCTTc().getTcPr().addNewGridSpan();
	}

	grdSpan.setVal(BigInteger.valueOf((long) span));

	/*
	 * row가 0인경우 바로 아래래 로우의 컬럼수도 일치하도록 셀을 추가한다. 추가하지않는경우 컬럼셀의 수가 불일치한 상태로
	 * 문서가 만들어진다.
	 */

	// if (rowNum == 0)
	// {
	// addTableCell(DIRECTION._0, table, rowNum, span);
	// } else
	// {
	// addTableCell(DIRECTION.UP_DOWN, table, rowNum, span);
	// }

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:34,代码来源:MSWord.java

示例3: copyControl

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * Copies the given {@link XWPFSDT} in the given output {@link IBody}.
 * 
 * @param outputBody
 *            the output {@link IBody}
 * @param control
 *            the {@link XWPFSDT} to insert
 */
private void copyControl(IBody outputBody, XWPFSDT control) {
    final CTSdtBlock sdt;
    if (outputBody instanceof XWPFDocument) {
        sdt = ((XWPFDocument) outputBody).getDocument().getBody().addNewSdt();
    } else if (outputBody instanceof XWPFHeaderFooter) {
        sdt = ((XWPFHeaderFooter) outputBody)._getHdrFtr().addNewSdt();
    } else if (outputBody instanceof XWPFFootnote) {
        sdt = ((XWPFFootnote) outputBody).getCTFtnEdn().addNewSdt();
    } else if (outputBody instanceof XWPFTableCell) {
        sdt = ((XWPFTableCell) outputBody).getCTTc().addNewSdt();
    } else {
        throw new IllegalStateException("can't insert control in " + outputBody.getClass().getCanonicalName());
    }
    // TODO we miss POI write API
    // XWPFSDT c = new XWPFSDT(sdt, outputBody);
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:25,代码来源:UserContentRawCopy.java

示例4: getGridSpan

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
private static int getGridSpan(XWPFTableCell cell) {
    if (cell == null)
        return -1;
    CTTcPr tcPr = cell.getCTTc().getTcPr();

    if (tcPr == null)
        return 1;

    CTDecimalNumber number = tcPr.getGridSpan();

    if (number == null) {
        return 1;
    }
    else {
        return number.getVal().intValue();
    }
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:18,代码来源:WordDocxTableParser.java

示例5: mergeCellsHorizonal

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * 合并行单元格
 * @param table
 * @param row
 * @param fromCol
 * @param toCol
 */
public void mergeCellsHorizonal(XWPFTable table, int row, int fromCol,
		int toCol) {
	for (int colIndex = fromCol; colIndex <= toCol; colIndex++) {
		XWPFTableCell cell = table.getRow(row).getCell(colIndex);
		CTTcPr tcPr = cell.getCTTc().getTcPr();
		if (null == tcPr)
			tcPr = cell.getCTTc().addNewTcPr();
		CTHMerge hMerge = tcPr.addNewHMerge();
		if (colIndex == fromCol) {
			// The first merged cell is set with RESTART merge value
			hMerge.setVal(STMerge.RESTART);
		} else {
			// Cells which join (merge) the first one, are set with CONTINUE
			hMerge.setVal(STMerge.CONTINUE);
		}
	}
}
 
开发者ID:Sayi,项目名称:poi-tl,代码行数:25,代码来源:NiceXWPFDocument.java

示例6: mergeCellsVertically

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * 合并列单元格
 * @param table
 * @param col
 * @param fromRow
 * @param toRow
 */
public void mergeCellsVertically(XWPFTable table, int col, int fromRow,
		int toRow) {

	for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) {

		XWPFTableCell cell = table.getRow(rowIndex).getCell(col);
		CTTcPr tcPr = cell.getCTTc().getTcPr();
		if (null == tcPr)
			tcPr = cell.getCTTc().addNewTcPr();
		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);
		}
	}
}
 
开发者ID:Sayi,项目名称:poi-tl,代码行数:27,代码来源:NiceXWPFDocument.java

示例7: mergeCellsVertically

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * 수직셀 병합
 *
 * @param table
 * @param col
 * @param fromRow
 * @param toRow
 *            절대위치
 */
public 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) {
			// The first merged cell is set with RESTART merge value
			cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART);
		} else {
			// Cells which join (merge) the first one, are set with CONTINUE
			cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE);
		}
	}
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:25,代码来源:MSWord.java

示例8: caseCell

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
@Override
public XWPFParagraph caseCell(Cell cell) {
    final XWPFTableCell newCell = currentGeneratedRow.createCell();
    final CTTc ctCell = (CTTc) cell.getTableCell().getCTTc().copy();
    ctCell.getPList().clear();
    ctCell.getTblList().clear();
    newCell.getCTTc().set(ctCell);

    final IBody savedGeneratedDocument = generatedDocument;
    final XWPFParagraph savedGeneratedParagraph = currentGeneratedParagraph;
    final XWPFParagraph savedTemplateParagraph = currentTemplateParagraph;
    generatedDocument = newCell;
    try {
        doSwitch(cell.getTemplate());
    } finally {
        generatedDocument = savedGeneratedDocument;
        currentGeneratedParagraph = savedGeneratedParagraph;
        currentTemplateParagraph = savedTemplateParagraph;
    }

    return currentGeneratedParagraph;
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:23,代码来源:M2DocEvaluator.java

示例9: parseTable

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * Parses a {@link Table}.
 * 
 * @param wtable
 *            the table to parse
 * @return the created object
 * @throws DocumentParserException
 *             if a problem occurs while parsing.
 */
protected Table parseTable(XWPFTable wtable) throws DocumentParserException {
    if (wtable == null) {
        throw new IllegalArgumentException("parseTable can't be called on a null argument.");
    }
    Table table = (Table) EcoreUtil.create(TemplatePackage.Literals.TABLE);
    table.setTable(wtable);
    for (XWPFTableRow tablerow : wtable.getRows()) {
        Row row = (Row) EcoreUtil.create(TemplatePackage.Literals.ROW);
        table.getRows().add(row);
        row.setTableRow(tablerow);
        for (XWPFTableCell tableCell : tablerow.getTableCells()) {
            Cell cell = (Cell) EcoreUtil.create(TemplatePackage.Literals.CELL);
            row.getCells().add(cell);
            cell.setTableCell(tableCell);
            AbstractBodyParser parser = getNewParser(tableCell);
            cell.setTemplate(parser.parseTemplate());
        }
    }
    return table;
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:30,代码来源:AbstractBodyParser.java

示例10: getTitleMap

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * 获取表头数据
 * 
 * @param table
 * @param index
 * @return
 */
private Map<String, Integer> getTitleMap(XWPFTable table, int index, int headRows) {
    if (index < headRows) {
        throw new WordExportException(WordExportEnum.EXCEL_NO_HEAD);
    }
    Map<String, Integer> map = new HashMap<String, Integer>();
    String text;
    for (int j = 0; j < headRows; j++) {
        List<XWPFTableCell> cells = table.getRow(index - j - 1).getTableCells();
        for (int i = 0; i < cells.size(); i++) {
            text = cells.get(i).getText();
            if (StringUtils.isEmpty(text)) {
                throw new WordExportException(WordExportEnum.EXCEL_HEAD_HAVA_NULL);
            }
            map.put(text, i);
        }
    }
    return map;
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:26,代码来源:ExcelEntityParse.java

示例11: parseThisTable

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * 解析这个表格
 * 
 * @author JueYue
 *  2013-11-17
 * @param table
 * @param map
 */
private void parseThisTable(XWPFTable table, Map<String, Object> map) throws Exception {
    XWPFTableRow row;
    List<XWPFTableCell> cells;
    Object listobj;
    for (int i = 0; i < table.getNumberOfRows(); i++) {
        row = table.getRow(i);
        cells = row.getTableCells();
        listobj = checkThisTableIsNeedIterator(cells.get(0), map);
        if (listobj == null) {
            parseThisRow(cells, map);
        } else if (listobj instanceof ExcelListEntity) {
            table.removeRow(i);// 删除这一行
            new ExcelEntityParse().parseNextRowAndAddRow(table, i, (ExcelListEntity) listobj);
            i = i + ((ExcelListEntity) listobj).getList().size() - 1;//删除之后要往上挪一行,然后加上跳过新建的行数
        } else {
            ExcelMapParse.parseNextRowAndAddRow(table, i, (List) listobj);
            i = i + ((List) listobj).size() - 1;//删除之后要往上挪一行,然后加上跳过新建的行数
        }
    }
}
 
开发者ID:rushingpig,项目名称:poix,代码行数:29,代码来源:ParseWord07.java

示例12: isVMerge

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
private static boolean isVMerge(XWPFTableCell cell) {
    if (cell == null)
        return false;
    CTTcPr tcPr = cell.getCTTc().getTcPr();
    if (tcPr == null)
        return false;

    return tcPr.isSetVMerge();
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:10,代码来源:WordDocxTableParser.java

示例13: isVMergeRestart

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
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);
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:11,代码来源:WordDocxTableParser.java

示例14: parseThisTable

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
/**
 * 解析这个表格
 * 
 * @Author JueYue
 * @date 2013-11-17
 * @param table
 * @param map
 */
private void parseThisTable(XWPFTable table, Map<String, Object> map) throws Exception {
    XWPFTableRow row;
    List<XWPFTableCell> cells;
    Object listobj;
    ExcelEntityParse excelEntityParse = new ExcelEntityParse();
    for (int i = 0; i < table.getNumberOfRows(); i++) {
        row = table.getRow(i);
        cells = row.getTableCells();
        if (cells.size() == 1) {
            listobj = checkThisTableIsNeedIterator(cells.get(0), map);
            if (listobj == null) {
                parseThisRow(cells, map);
            } else if (listobj instanceof ExcelListEntity) {
                table.removeRow(i);// 删除这一行
                excelEntityParse.parseNextRowAndAddRow(table, i, (ExcelListEntity) listobj);
            } else {
                table.removeRow(i);// 删除这一行
                ExcelMapParse.parseNextRowAndAddRow(table, i, (List) listobj);
            }
        } else {
            parseThisRow(cells, map);
        }
    }
}
 
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:33,代码来源:ParseWord07.java

示例15: createHeader

import org.apache.poi.xwpf.usermodel.XWPFTableCell; //导入依赖的package包/类
private void createHeader(XWPFTable table, List<RenderData> headers) {
    if (null == headers || headers.isEmpty()) return;
    int i = 0;
    for (RenderData head : headers) {
        TextRenderData textHead = (TextRenderData) head;
        Style style = textHead.getStyle();
        String color = null == style ? null : style.getColor();
        XWPFTableCell cell = table.getRow(0).getCell(i);
        String[] fragment = textHead.getText().split(TextRenderPolicy.REGEX_LINE_CHARACTOR);
        if (null != fragment) {
            cell.setText(fragment[0]);
            for (int j = 1; j < fragment.length; j++) {
                XWPFParagraph addParagraph = cell.addParagraph();
                addParagraph.createRun().setText(fragment[j]);
            }
        }
        if (null != color) table.getRow(0).getCell(i).setColor(color);
        i++;
    }
}
 
开发者ID:Sayi,项目名称:poi-tl,代码行数:21,代码来源:SimpleTableRenderPolicy.java


注:本文中的org.apache.poi.xwpf.usermodel.XWPFTableCell类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。