Bug 42256 - unkown grbit '16' error while reading excel file.
Summary: unkown grbit '16' error while reading excel file.
Status: RESOLVED DUPLICATE of bug 42564
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: HP HP-UX
: P1 blocker with 2 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2007-04-25 19:37 UTC by sara
Modified: 2008-03-27 05:37 UTC (History)
1 user (show)

Excel file that caused issues even after deleting all data (13.50 KB, text/plain)
2007-04-25 19:48 UTC, sara

Note You need to log in before you can comment on or make changes to this bug.
Description sara 2007-04-25 19:37:24 UTC
Hi, I am trying to read an excel file that was modified on excel 2003. Getting 
below exceptions:

        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at org.apache.poi.hssf.record.RecordFactory.createRecord
        at org.apache.poi.hssf.record.RecordFactory.createRecords
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
        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
        at org.apache.poi.hssf.record.formula.Ptg.createParsedExpressionTokens
        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 -
	      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 

I will attach the spread sheet that started causing issues. Thanks.
Comment 1 sara 2007-04-25 19:48:21 UTC
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
Comment 2 Marco 2008-03-27 02:34:34 UTC
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
Comment 3 Nick Burch 2008-03-27 05:37:12 UTC

*** This bug has been marked as a duplicate of bug 42564 ***