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


Java XWPFTable.removeRow方法代码示例

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


在下文中一共展示了XWPFTable.removeRow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseThisTable

import org.apache.poi.xwpf.usermodel.XWPFTable; //导入方法依赖的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

示例2: parseNextRowAndAddRow

import org.apache.poi.xwpf.usermodel.XWPFTable; //导入方法依赖的package包/类
/**
 * 解析下一行,并且生成更多的行
 * 
 * @Author JueYue
 * @date 2013-11-18
 * @param table
 * @param listobj2
 */
public static void parseNextRowAndAddRow(XWPFTable table, int index, List<Object> list)
                                                                                       throws Exception {
    XWPFTableRow currentRow = table.getRow(index);
    String[] params = parseCurrentRowGetParams(currentRow);
    table.removeRow(index);// 移除这一行
    int cellIndex = 0;// 创建完成对象一行好像多了一个cell
    for (Object obj : list) {
        currentRow = table.createRow();
        for (cellIndex = 0; cellIndex < currentRow.getTableCells().size(); cellIndex++) {
            currentRow
                .getTableCells()
                .get(cellIndex)
                .setText(
                    PoiPublicUtil.getValueDoWhile(obj, params[cellIndex].split("\\."), 0)
                        .toString());
        }
        for (; cellIndex < params.length; cellIndex++) {
            currentRow.createCell().setText(
                PoiPublicUtil.getValueDoWhile(obj, params[cellIndex].split("\\."), 0)
                    .toString());
        }
    }

}
 
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:33,代码来源:ExcelMapParse.java

示例3: parseThisTable

import org.apache.poi.xwpf.usermodel.XWPFTable; //导入方法依赖的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

示例4: render

import org.apache.poi.xwpf.usermodel.XWPFTable; //导入方法依赖的package包/类
@Override
public void render(XWPFTable table, Object data) {
	TableRenderData tableData = (TableRenderData) data;
	List<Object> datas = tableData.getDatas();
	if (null == datas || datas.isEmpty()) {
		table.getRow(1).getCell(0).removeParagraph(0);
		table.getRow(1).getCell(0).setText(tableData.getNoDatadesc());
	} else {
		// XWPFTableRow row = table.getRow(1);

		table.removeRow(1);
		for (Object obj : datas) {
			XWPFTableRow row = table.insertNewTableRow(1);
			String str = obj.toString();
			String[] split = str.split(";");
			XWPFTableCell cell0 = row.createCell();
			cell0.setText(split[0]);
			XWPFTableCell cell1 = row.createCell();
			cell1.setText(split[1]);
			XWPFTableCell cell2 = row.createCell();
			cell2.setText(split[2]);
		}
	}

}
 
开发者ID:Sayi,项目名称:poi-tl,代码行数:26,代码来源:MyTableRenderPolicy.java

示例5: createNewTable

import org.apache.poi.xwpf.usermodel.XWPFTable; //导入方法依赖的package包/类
/**
 * Create new Table.
 * TODO OHA fix bug in nested table on usercontent (else case in code)
 * 
 * @param document
 *            document
 * @param inputTable
 *            input Table
 * @return get Table
 */
private XWPFTable createNewTable(IBody document, XWPFTable inputTable) {
    final XWPFTable generatedTable;
    final CTTbl copy = (CTTbl) inputTable.getCTTbl().copy();
    if (document instanceof XWPFDocument) {
        generatedTable = ((XWPFDocument) document).createTable();
    } else if (document instanceof XWPFHeaderFooter) {
        final XWPFHeaderFooter headerFooter = (XWPFHeaderFooter) document;
        final int index = headerFooter._getHdrFtr().getTblArray().length;
        final CTTbl cttbl = headerFooter._getHdrFtr().insertNewTbl(index);
        XWPFTable newTable = new XWPFTable(cttbl, headerFooter);
        if (newTable.getRows().size() > 0) {
            newTable.removeRow(0);
        }
        headerFooter.insertTable(index, newTable);
        generatedTable = headerFooter.getTables().get(index);
        generatedTable.getCTTbl().set(copy);
    } else if (document instanceof XWPFTableCell) {
        XWPFTableCell tCell = (XWPFTableCell) document;
        int tableRank = tCell.getTables().size();
        tCell.insertTable(tableRank, new XWPFTable(copy, tCell, 0, 0));
        generatedTable = tCell.getTables().get(tableRank);
    } else {
        throw new UnsupportedOperationException("unknown type of IBody : " + document.getClass());
    }
    return generatedTable;
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:37,代码来源:UserContentRawCopy.java


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