http://poi.apache.org/components/spreadsheet/quick-guide.html#Iterator
把上面的代码拿出来加点注释,好看一点
int rowStart = Math.min(15, sheet.getFirstRowNum());
int rowEnd = Math.max(1400, sheet.getLastRowNum());
//此方法返回值
List<List<Cell>> sheetCells = new ArrayList<>();
for (int rowNum = rowStart; rowNum < rowEnd; rowNum++) {
Row r = sheet.getRow(rowNum);
if (r == null) {
// This whole row is empty
// Handle it as needed
continue;
}
int lastColumn = Math.max(r.getLastCellNum(), MY_MINIMUM_COLUMN_COUNT);
//每一行一个list
List<Cell> rowCells = new ArrayList<>();
for (int cn = 0; cn < lastColumn; cn++) {
//如果返回的cell是空白blank,就当作null处理 -①
Cell c = r.getCell(cn, Row.RETURN_BLANK_AS_NULL);
if (c == null) {
// The spreadsheet is empty in this cell
} else {
// Do something useful with the cell's contents
//c不为null就添加到集合里 -②
rowCells.add(c);
}
}
//最后在这里判断rowCells是否是empty的 -③
if (!rowCells.isEmpty()) {
sheetCells.add(rowCells);
}
}