Hi, I am trying to read an excel file that was modified on excel 2003. Getting below exceptions: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:274) at org.apache.poi.hssf.record.RecordFactory.createRecord (RecordFactory.java:213) at org.apache.poi.hssf.record.RecordFactory.createRecords (RecordFactory.java:149) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init> (HSSFWorkbook.java:183) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init> (HSSFWorkbook.java:230) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init> (HSSFWorkbook.java:211) at ReadInvSheet.main(ReadInvSheet.java:47) Caused by: org.apache.poi.hssf.record.RecordFormatException: Unknown grbit '16' at org.apache.poi.hssf.record.formula.ArrayPtg.readTokenValues (ArrayPtg.java:98) at org.apache.poi.hssf.record.formula.Ptg.createParsedExpressionTokens (Ptg.java:109) at org.apache.poi.hssf.record.NameRecord.fillFields(NameRecord.java:739) at org.apache.poi.hssf.record.Record.<init>(Record.java:55) at org.apache.poi.hssf.record.NameRecord.<init>(NameRecord.java:142) ... 10 more Error in Reading : org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance, the following exception occured: null Code snippet that is trying to read excel - try { fs = new FileInputStream(fileToBeRead); System.out.println(" file read" ); FI = new FileInputStream(propertyFile) ; FW = new FileWriter(fileToBeWritten); } catch(FileNotFoundException e) { throw new Exception(e); } catch(IOException e) { throw new Exception(e); } System.out.println("Before HSSFWorkbook Initiation"); HSSFWorkbook workbook = new HSSFWorkbook(fs); System.out.println("After HSSFWorkbook Initiation"); Exception are right at initializing HSSFWorkbook() - HSSFWorkbook workbook = new HSSFWorkbook(fs); We are using POI_3.0_Alpha.jar. I tried test with poi-3.0-rc3-20070402.jar and still have same error. I tried deleting all tabs in the excel file step by step and tried at last with no data also and I still have same error. But when I try create empty excel on my machine(office 2000) and used it, program works fine. Could this be the issue with office 2003 compatibility? It is failing even with no data in the file that was created/updated on the machine which has office 2003. Since no data and no array formulas in the excel file, control is still going to Ptg and ArrayPtg classes and calling readTokenValues(). I will attach the spread sheet that started causing issues. Thanks.
Created attachment 20048 [details] Excel file that caused issues even after deleting all data After deleting all data from the attached spreadsheet also caused same errors. Attached the same file. I tried save as of type excel 97-2000 also with no luck.
I have the same problem on Windows XP and Linux (Ubuntu). Poi version: poi-3.0.2-FINAL-20080204.jar Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:199) at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:117) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:207) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:148) at it.ingeniumtech.test.excel.Poi.main(Poi.java:25) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedConstructorAccessor5.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:187) ... 4 more Caused by: org.apache.poi.hssf.record.RecordFormatException: Unknown grbit '16' at org.apache.poi.hssf.record.formula.ArrayPtg.readTokenValues(ArrayPtg.java:99) at org.apache.poi.hssf.record.formula.Ptg.createParsedExpressionTokens(Ptg.java:110) at org.apache.poi.hssf.record.NameRecord.fillFields(NameRecord.java:778) at org.apache.poi.hssf.record.Record.<init>(Record.java:55) at org.apache.poi.hssf.record.NameRecord.<init>(NameRecord.java:139) ... 8 more
*** This bug has been marked as a duplicate of bug 42564 ***