I'm having a weird problem about reading excel file, I created a file to test but still have the same problem, the workbook is returning that has 0 sheets but it does have 3 sheets: here's my code:
FileInputStream fs = new FileInputStream(new File("C:/Users/TO124415/Desktop/test.xlsx"));
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet hs = wb.getSheetAt(0);
int number = wb.getNumberOfSheets();
System.out.println(number);
FormulaEvaluator form = wb.getCreationHelper().createFormulaEvaluator();
HSSFCell value = wb.getSheetAt(0).getRow(14).getCell(1);
for (Row rw : hs){
for(Cell cell : rw){
switch(form.evaluateInCell(cell).getCellType()){
case Cell.CELL_TYPE_NUMERIC:
System.out.println(cell.getNumericCellValue());
case Cell.CELL_TYPE_STRING:
System.out.println(cell.getStringCellValue());
}
}
}
I'm having this error:
Exception in thread "main" java.lang.IllegalArgumentException: Sheet index (0) is out of range (no sheets)
This error must be if I set getSheetAt(3) because I know that the index is starting from 0 not 1. Someone can explain please?