gents, i have a problem reading excel file with while loop. Program works by matching a string value given then gets from an excel cell data and basically it works. But when there are two or more same string value, it continues the loop and get the last correspondent one. What i want to terminate after first or second and so on ... nevertheless i need hasNext(); do you have any clue?
Code:
while(rowIterator.hasNext() ) {
Row row = rowIterator.next();
//For each row, iterate through each columns
Iterator<Cell> cellIterator = row.cellIterator();
while(cellIterator.hasNext()){
Cell cell = cellIterator.next();
switch(cell.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
// System.out.print(cell.getBooleanCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_NUMERIC:
// System.out.print(cell.getNumericCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_STRING:
if (cell.getStringCellValue().equals(veri_Tipi)){
CellReference nextCellAdress = new CellReference(row.getRowNum(),cell.getColumnIndex()+2);
Row next_Cell_Row = sheet.getRow(nextCellAdress.getRow());
Cell next_Cell = next_Cell_Row.getCell(nextCellAdress.getCol());
switch(next_Cell.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
break;
case Cell.CELL_TYPE_BLANK:
break;
case Cell.CELL_TYPE_NUMERIC:
bilancoVeriExcel = count;//next_Cell.getNumericCellValue();
break;
case Cell.CELL_TYPE_STRING:
break;
}
}
}
}
}