Bug 12561

Summary: HSSFWorkbook throws Exceptions
Product: POI Reporter: T.Miyaji <miya>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: minor    
Priority: P3    
Version: 1.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: there are two xls files in archive, which cause exception. Sorry, but String are almost in Japanese.

Description T.Miyaji 2002-09-12 06:06:47 UTC
I wrote a following code to read xls file that is created by
Japanese MS-Excel 2000.

public class Test {
  public static void main ( String[] args ) 
		throws IOException {
    if ( args.length != 1 ) {
      System.err.println ( "Usage: java Test xls_file" );
      System.exit ( 0 );
    }
    FileInputStream fi = new FileInputStream ( args[1] );
    HSSFWorkbook wb = new HSSFWorkbook ( fi );
    fi.close ( );
  }
}

It's almost O.K.
But, reading some xls file, HSSFWorkbook throws following exceptions.

1) Exception in thread "main" java.lang.NullPointerException
	at org.apache.poi.hssf.record.SSTRecord.getString(SSTRecord.java:309)
	at org.apache.poi.hssf.model.Workbook.getSSTString(Workbook.java:576)
	at org.apache.poi.hssf.usermodel.HSSFCell.<init>(HSSFCell.java:305)
	at org.apache.poi.hssf.usermodel.HSSFRow.createCellFromRecord(HSSFRow.java:233)
	at
org.apache.poi.hssf.usermodel.HSSFSheet.setPropertiesFromSheet(HSSFSheet.java:171)
	at org.apache.poi.hssf.usermodel.HSSFSheet.<init>(HSSFSheet.java:134)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:154)


2) Exception in thread "main" java.lang.NegativeArraySizeException
	at
org.apache.poi.hssf.record.SSTDeserializer.readStringRemainder(SSTDeserializer.java:335)
	at
org.apache.poi.hssf.record.SSTDeserializer.processContinueRecord(SSTDeserializer.java:320)
	at
org.apache.poi.hssf.record.SSTRecord.processContinueRecord(SSTRecord.java:540)
	at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:210)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:140)

regards.
Comment 1 Jason Height 2002-09-12 07:02:30 UTC
Can you attach the workbook(s) that fail so we have an easily runnable test 
case?

Jason

PS This can be done using the Create new attachment feature in bugzilla.
Comment 2 T.Miyaji 2002-09-12 07:38:01 UTC
Created attachment 3027 [details]
there are two xls files in archive, which cause exception. Sorry, but String are almost in Japanese.
Comment 3 Andy Oliver 2002-09-12 10:58:03 UTC
Please also test this against the HEAD from cvs or against last nights build.  A
patch was recently applied to it for better handling of Japanese specifically.  
Comment 4 Andy Oliver 2002-10-01 21:47:36 UTC
if the requested information is not provided in the next week or so I'll close
this bug.
Comment 5 T.Miyaji 2002-10-02 03:58:54 UTC
Sorry for delaying response, 
But, Some exception still be thrown.

thanks.
Comment 6 Avik Sengupta 2003-10-27 02:59:35 UTC
Fixed in latest CVS. Thanks Jason...

Will go into next release 2.0pre4