I am trying to read a excel file which is in xlsx format. But i am getting Result too large and Invalid handle exception . I am putting the file instance in a FileInputStream object and trying to set that object in XSSFWorkbook. But i am getting this exception .
I am working in an environment where Microsoft office is not installed and there is open office.I am not editing my xlsx file in open office.But i opened the file in open office and then tried to run the poi code.Is there any problem occurring due to this?
I am giving my code snippet and the exception below also the jars i am using
commons-codec-1.10
commons-collections4-4.1
commons-io-2.5
commons-logging-1.2
curvesapi-1.04
ooxml-schemas-1.0
poi-3.17
poi-excelant-3.17
poi-ooxml-3.17
xmlbeans-2.3.0
This is the code from where i am getting an exception,
private void openWorkbook(String fileName) throws IOException {
FileInputStream excelFile = new FileInputStream(new File(fileName));
try {
this.setWorkbook(new XSSFWorkbook(excelFile)); // here the exception is coccuring
} catch (Exception e) {
e.printStackTrace();
}finally{
excelFile.close();
}
}
I believe the setWorkBook method can not handle the size of the workbook .
And the exception i am getting is
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:63)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:580)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:165)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:300)
at com.test.ExcelManager.openWorkbook(ExcelManager.java:26)
at com.test.ExcelManager.<init>(ExcelManager.java:18)
at com.test.ActivityLauncher.main(ActivityLauncher.java:87)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56)
at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:60)
... 6 more
Caused by: java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyle.getTableStyleElementList()Ljava/util/List;
at org.apache.poi.xssf.usermodel.XSSFTableStyle.<init>(XSSFTableStyle.java:87)
at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:247)
at org.apache.poi.xssf.model.StylesTable.<init>(StylesTable.java:141)
... 12 more
Exception in thread "main" java.lang.NullPointerException
at com.test.ExcelManager.<init>(ExcelManager.java:19)
at com.test.ActivityLauncher.main(ActivityLauncher.java:87)
Please help.