First of all, the code below has worked without problems for a while now.
I receive excel files from a colleague, which I read and upload with this program.
Recently the colleague was replaced, and I receive the files from another person.
I’ll check with him as well what exactly he does with the excel file.
Anyway, the first excel file I receive from the new colleague is getting me frustrated.
The code below exits on the WorkbookFactory.create(fis) call. No exceptions are thrown
and the program goes straight to the finally clause…
try {
fis = new FileInputStream(f);
Workbook wb = WorkbookFactory.create(fis);
Sheet ws = wb.getSheetAt(0);
if (ws == null) {
throw new ParseException("No sheet found on index 0", 1);
}
Iterator rowIt = ws.rowIterator();
while (rowIt.hasNext()) {
Row row = (Row) rowIt.next();
if (row.getRowNum() != 0 && isArticleRow(row)) {
Article article = parseArticleData(row);
if (article != null) {
priceList.getArticles().add(article);
}
}
}
String vendorNumber = getVendorNumber(priceList);
priceList.setVendorNumber(vendorNumber);
priceList.setReadCorrectly(true);
System.out.println("DONE");
} catch (Exception e) {
System.out.println(e.getMessage());
_log.error(e.getMessage());
if (priceList != null) {
priceList.setReadCorrectly(false);
}
} finally {
if (fis != null) {
fis.close();
}
return priceList;
}
I tried debugging, but I experience the same behaviour, and without an
exception being thrown, I’m not sure how to proceed.
Thanks in advance for your feedback.
Catch Throwable and see instead of Exception. It should work.