Bug 35564 - HSSFCell.java: NullPtrExc in isGridsPrinted() and getProtect() when HSSFWorkbook is created from file
Summary: HSSFCell.java: NullPtrExc in isGridsPrinted() and getProtect() when HSSFWorkb...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords: ErrorMessage
Depends on:
Blocks:
 
Reported: 2005-06-30 17:44 UTC by Szilard barany
Modified: 2007-01-16 01:42 UTC (History)
0 users



Attachments
Test file (56.50 KB, application/vnd.ms-excel)
2005-07-06 11:36 UTC, Szilard barany
Details

Note You need to log in before you can comment on or make changes to this bug.
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