Bug 8858 - Exception on writing a workbook
Summary: Exception on writing a workbook
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-dev
Hardware: PC other
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2002-05-07 09:16 UTC by Dieter Bogdoll
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)

Excel Sheet which reproduces the exception (16.22 KB, application/octet-stream)
2002-05-14 08:35 UTC, Dieter Bogdoll
Excelsheet without the picture (5.76 KB, application/octet-stream)
2002-05-14 12:46 UTC, Dieter Bogdoll

Note You need to log in before you can comment on or make changes to this bug.
Description Dieter Bogdoll 2002-05-07 09:16:06 UTC
The following code:
	public static void main(String[] aArgs) throws IOException {
		InputStream in = PoiTest.class.getResourceAsStream("KW_d.xls");
		HSSFWorkbook workBook = new HSSFWorkbook(in);
		int nbSheets = workBook.getNumberOfSheets();
		System.out.println("The Excel document has "+nbSheets+" sheet");
		System.out.println("The names are:");
		for( int i=0; i<nbSheets; ++i) {
			System.out.println( ""+i+". "+workBook.getSheetName(i));
		OutputStream out = new FileOutputStream
		workBook.write( out );

Throws the following exception:
	at org.apache.poi.util.StringUtil.putUncompressedUnicode
	at org.apache.poi.hssf.record.UnicodeString.serialize
	at org.apache.poi.hssf.record.Record.serialize(Record.java:168)
	at org.apache.poi.hssf.record.SSTRecord.serialize(SSTRecord.java:541)
	at org.apache.poi.hssf.model.Workbook.serialize(Workbook.java:664)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write
	at com.consultens.poi.PoiTest.main(PoiTest.java:72)
Exception in thread "main"
Comment 1 Dieter Bogdoll 2002-05-14 07:13:49 UTC
Do you need additional information to tackle this bug? All our corporate
excelsheets I try to use ends in this or a simillary error. Perhaps I'm using
a wrong excel version, which excel version should be used with POI?

I hope you can soon fix this bug, because otherwise we have to look for another
solution for our excel sheets. Although I would like to use a 100% java solution
like POI.


Comment 2 Glen Stampoultzis 2002-05-14 07:27:13 UTC
They actual excel file causing the crash would be handy.
Comment 3 Dieter Bogdoll 2002-05-14 08:35:23 UTC
Created attachment 1852 [details]
Excel Sheet which reproduces the exception
Comment 4 Andy Oliver 2002-05-14 12:00:59 UTC
I'll look at it.  You must use Excel 97 or newer.

This file has =Embed(blabla) functions in it.  I've never seen such a thing. 
Secondly it has embedded graphics.  My money is on the =Embed(blabla). 
Regardless I'll look at it probably this weekend.  This is 2.0 stuff.  (we don't
claim to support embedded graphics or formulas)
Comment 5 Dieter Bogdoll 2002-05-14 12:22:41 UTC
Hi Andy,

thanks for your answer. Which version of Excel is now exactly supported?

I don't think, that the Image is the problem. Probably the =Embed(blabla).
I didn't created the excel sheets, so I don't know what the =Embed(blabla)
stuff is at all. Do you know how they can be removed?
Comment 6 Andy Oliver 2002-05-14 12:29:53 UTC
I said Excel 97+.  Delete the =Embed(xx) (and probably the image with it) and
paste the image directly.
Comment 7 Dieter Bogdoll 2002-05-14 12:46:56 UTC
Created attachment 1857 [details]
Excelsheet without the picture
Comment 8 Dieter Bogdoll 2002-05-14 12:48:42 UTC
I removed the picture from the excel sheet and saved the file with Excel 2000.
The same error still occures.
Comment 9 Glen Stampoultzis 2002-05-14 13:48:52 UTC
Looks like it might be something to do with the characterset.  Need to 
investigate more.
Comment 10 Andy Oliver 2002-05-14 13:50:19 UTC
is this possibly more RTF problems?  (rich text)
Comment 11 Glen Stampoultzis 2002-05-14 23:21:09 UTC
Nope, rtf's generally cause problems with reading.  a unicode problem i think.
Comment 12 Andy Oliver 2002-05-15 00:05:16 UTC
so are you looking at this or do you want me to?  I'm about to commit changes to
the record generator to make it autodefine tests.
Comment 13 Glen Stampoultzis 2002-05-15 23:24:45 UTC
Andy was right.  It's an rich text problem.  Deleting cell F8 fixed the 
problem.  I didn't spot is straight away because it's doesn't look obviously 

We don't support this one yet.  I think it was planned for 2.0 but maybe some 
kind sole will post a workaround that we may be able to put in 1.5.1.
Comment 14 Dieter Bogdoll 2002-05-16 13:24:17 UTC
Hi Glen,

how can I see which cells are wrong formatted? I see no differences from this
cell to the other cells?
Comment 15 Glen Stampoultzis 2002-05-16 23:45:29 UTC
I had a hard time spotting it too.  I only discovered it through debugging the 
workbook.  It doesn't appear formatted to me but it's definately being stored 
as rich text.