Error reading from excel file after 20th column

While reading data from excel using apache poi library , if table has more than 20 columns then it doesn't fetch the data from the 21st column but the value from next column and so on for a particular row. The code snippet is written below:\[code\]for (int rowNo = 1; rowNo <= noOfRows; rowNo++) { HSSFRow row = worksheet.getRow(rowNo); int cellCounter = -1; int currentCell = 0; @SuppressWarnings("unchecked") Iterator<HSSFCell> cells = row.cellIterator(); while (cells.hasNext()) { HSSFCell cell = (HSSFCell) cells.next(); currentCell = cell.getCellNum(); cellCounter++; if (currentCell != cellCounter) { while (cellCounter < currentCell) { listOfValues.add(""); cellCounter++; } } // Getting the 22nd column instead of 21st and so on listOfValues.add(cell.getStringCellValue()); }}\[/code\]
 
Top