想要读取特定列并迭代该行。下面的代码不提供输出(未找到错误)。
while (rowIterator.hasNext())
{
Row row = rowIterator.next();
Cell cell=row.getCell(1);
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext())
{
cell = cellIterator.next();
System.out.println(cell.getNumericCellValue());
}
循环时不进入!
答案 0 :(得分:0)
celliterator
用于逐行迭代行内的所有单元格。如果您想使用特定列,则不应使用cellIterator
,
while (rowIterator.hasNext()){
Row row = rowIterator.next();
Cell cell=row.getCell(4); // for accessing 5th column
System.out.println(cell.getNumericCellValue());
}
请注意,如果您对此不明确,则明确使用getNumericCellValue()
,您应该使用与PopoFibo建议相同的内容。