I need to read file excel, and I am working with java spring boot, Apache poi. they told us
When working with the newer .xlsx file format, you would use the XSSFWorkbook, XSSFSheet, XSSFRow, and XSSFCell classes. To work with the older .xls format, use the HSSFWorkbook, HSSFSheet, HSSFRow, and HSSFCell classes.
this is my code:
Workbook workbook;
if (FileExtension == "xlsx"){
workbook = new XSSFWorkbook(excelFile);
}
else if (FileExtension == "xls"){
workbook = new HSSFWorkbook(excelFile);
}
Sheet datatypeSheet = workbook.getSheetAt(0);
Now im getting "workbook" might not have been initialized. How to solve that?