Bug 35564

Summary: HSSFCell.java: NullPtrExc in isGridsPrinted() and getProtect() when HSSFWorkbook is created from file
Product: POI Reporter: Szilard barany <szitya>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal Keywords: ErrorMessage
Priority: P2    
Version: 2.5-FINAL   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: Test file

Description Szilard barany 2005-06-30 17:44:28 UTC
The following errors occured
  ---------------------------
  Exception in thread main
  java.lang.NullPointerException
     at org.apache.poi.hssf.model.Sheet.isGridsPrinted(Sheet.java:1848)

  Exception in thread main
  java.lang.NullPointerException
     at org.apache.poi.hssf.usermodel.HSSFSheet.getProtect(HSSFSheet.java:841)
  ---------------------------

in the following code

  ---------------------------
  import java.io.FileInputStream;
  import java.io.IOException;

  import org.apache.poi.hssf.usermodel.HSSFSheet;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  import org.apache.poi.poifs.filesystem.POIFSFileSystem;

  public class GridSetError  {
    public GridSetError( String fileName ) {

      System.out.println( "fileName : " + fileName );
      try {
        POIFSFileSystem pfs = new POIFSFileSystem( new FileInputStream( fileName
) );
        HSSFWorkbook sourceWorkbook = new HSSFWorkbook( pfs );
        HSSFSheet sourceSheet = sourceWorkbook.getSheetAt( 0 );
        // Uncomment the following lines one at a time
        //System.out.println( sourceSheet.isGridsPrinted() ); 
        //System.out.println( sourceSheet.getProtect() );
      }
      catch( IOException ioE ) {}
    }

    public static void main(String[] args) {
      if( args.length > 0 ) {
        GridSetError gridSetError = new GridSetError( args[0] );
      }
    }
  }
  ---------------------------

Source XLS contains [GRIDSET] and [PROTECT] records (checked with BiffViewer).

poi-2.5.1-final-20040804
Comment 1 Avik Sengupta 2005-07-05 14:25:46 UTC
Please attach a stripped down offending xl sheet. 
Comment 2 Szilard barany 2005-07-06 11:36:43 UTC
Created attachment 15603 [details]
Test file
Comment 3 Jason Height 2005-08-25 05:25:54 UTC
Can you please confirm that the attached file was actually written by excel. It
has some really wierd record structures.

Jason
Comment 4 Avik Sengupta 2007-01-16 01:42:42 UTC
Works as of 12Jan2007, Testcase added. 
http://issues.apache.org/bugzilla/show_bug.cgi?id=41366