本文整理汇总了Java中org.apache.poi.xwpf.usermodel.XWPFTable.getNumberOfRows方法的典型用法代码示例。如果您正苦于以下问题:Java XWPFTable.getNumberOfRows方法的具体用法?Java XWPFTable.getNumberOfRows怎么用?Java XWPFTable.getNumberOfRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xwpf.usermodel.XWPFTable
的用法示例。
在下文中一共展示了XWPFTable.getNumberOfRows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;//删除之后要往上挪一行,然后加上跳过新建的行数
}
}
}
示例2: 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);
}
}
}
示例3: fillTable
import org.apache.poi.xwpf.usermodel.XWPFTable; //导入方法依赖的package包/类
/**
* Fill a newly created word table with the data from an MTable.
*
* @param table
* The newly created word table
* @param mtable
* The MTable that describes the data and styles to insert
*/
private void fillTable(XWPFTable table, MTable mtable) {
List<MRow> rows = mtable.getRows();
// Iterate over the rows
for (int rowIdx = 0; rowIdx < rows.size(); rowIdx++) {
MRow mRow = rows.get(rowIdx);
// Get or create XWPF row
XWPFTableRow xwpfRow;
if (table.getNumberOfRows() > rowIdx) {
xwpfRow = table.getRow(rowIdx);
} else {
xwpfRow = table.createRow();
}
// Iterate over the columns
for (int colIdx = 0; colIdx < mtable.getColumnsCount(); colIdx++) {
// Get or create XWPF cell
XWPFTableCell xwpfCell;
if (xwpfRow.getTableCells().size() > colIdx) {
xwpfCell = xwpfRow.getCell(colIdx);
} else {
xwpfCell = xwpfRow.createCell();
}
// Populate cell
XWPFParagraph xwpfCellParagraph = xwpfCell.getParagraphs().get(0);
xwpfCellParagraph.setSpacingBefore(0);
xwpfCellParagraph.setSpacingAfter(0);
MCell mCell = null;
if (colIdx < mRow.getCells().size()) {
mCell = mRow.getCells().get(colIdx);
}
setCellContent(xwpfCell, mCell);
}
}
}