I need to check and validate the cells types from a single line in my XLS file. I like to read only one line, to avoid problems. Here's my code to read all the lines:
while (rowIterator.hasNext()) {
Row row = (Row) rowIterator.next();
// Descantando a primeira linha com o header
if (row.getRowNum() == 0) {
continue;
}
Iterator cellIterator = row.cellIterator();
ItemExcel item = new ItemExcel();
itens.add(item);
while (cellIterator.hasNext()) {
Cell cell = (Cell) cellIterator.next();
switch (cell.getColumnIndex()) {
case 0:
item.setDado0((int) cell.getNumericCellValue());
break;
case 1:
item.setDado1(formatter.formatCellValue(cell));
break;
case 2:
item.setDado2(formatter.formatCellValue(cell));
break;
case 3:
item.setDado3(formatter.formatCellValue(cell));
break;
case 4:
item.setDado4(formatter.formatCellValue(cell));
break;
case 5:
item.setDado5(cell.getNumericCellValue());
break;
}
}
}
But I need to only check a single line, how can I do this?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…