I need to read XLS files from Java. For that purpose I start evaluating jXLS framework. Unfortunately, I’m still getting following exception while trying to run example on their XLS reader reference page:
Exception in thread "main" net.sf.jxls.reader.XLSDataReadException: Can't read cell A4 on Sheet1 spreadsheet
at net.sf.jxls.reader.SimpleBlockReaderImpl.read(SimpleBlockReaderImpl.java:61)
at net.sf.jxls.reader.XLSSheetReaderImpl.read(XLSSheetReaderImpl.java:25)
at net.sf.jxls.reader.XLSReaderImpl.readSheet(XLSReaderImpl.java:45)
at net.sf.jxls.reader.XLSReaderImpl.read(XLSReaderImpl.java:31)
at com.oracle.sk.jxls.App.go(App.java:46)
at com.oracle.sk.jxls.App.main(App.java:19)
Changes I’ve made against original are:
- moved Department.java and Employee.java into the same package where main class is (in other words next to App.java)
- add empty no-args constructor to both
- change the varType (full class names for Employee and Department) everywhere in departments.xml accordingly
Both departments.xml and departmentdata.xls are taken directly from the XLS reader reference page. Department.java and Employee.java are downloaded from Simple beans page (on jXLS site too). If necessary, I can provide my complete Maven project.
Please, does anyone have a clue, why it is not working?
Thank you in advance.
I know it has been a while, but I did some debugging searching to answer this problem, an actually I found out something.
From the
departments.xmlyou see that the A4 cell is mapped todepartment.chief.name, but when it initializes your Department object, the chief property is null, so in the Department no-args constructor you should do something likechief = new Employee()Now it should work.