Bug 16560 - testBoolErr.xls crashes Excel '97
Summary: testBoolErr.xls crashes Excel '97
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-dev
Hardware: Other All
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2003-01-29 20:31 UTC by Danny Mui
Modified: 2005-03-20 17:06 UTC (History)
0 users

Junit generated excel file (5.00 KB, application/vnd.ms-excel)
2003-01-29 20:31 UTC, Danny Mui

Note You need to log in before you can comment on or make changes to this bug.
Description Danny Mui 2003-01-29 20:31:06 UTC
The file testBoolErr.xls generated by TestHSSFCell crashes Excel '97
Comment 1 Danny Mui 2003-01-29 20:31:36 UTC
Created attachment 4633 [details]
Junit generated excel file
Comment 2 Andy Oliver 2003-07-24 15:32:50 UTC
this one works in Excel v.X...
Comment 3 Michael Zalewski 2003-08-09 02:25:24 UTC
This does not work in any version of Excel, unless you run the testcase against 
the head. In that case, the testcase produces a spreadsheet that loads 
properly, but the testcase fails.

The reason is that the testcase calls HSSCell.setErrorValue( (byte) 1), which 
is an invalid argument. The valid arguments are

0   #NULL!
7   #DIV/0!
15  #VALUE!
23  #REF!
29  #NAME?
36  #NUM!
42  #N/A

These are the 7 error types allowed in Excel. There are no others. If you set 
the erro value of a BOOLERR record to any other value, the spreadsheet will not 
load in Excel.

Why these magic numbers? Put the error codewords together in a string and 
seperate each with a \0, like you would if you were programming in C. The magic 
numbers are the offsets to the beginning of each codeword.

0         1         2         3         4

I would work on a patch for this but... the HEAD is very strange right now. The 
performance branch merge seems to have changed *everything*.

My instinct is that BoolErrRecord should throw an exception if the client tries 
to set an unacceptable value. Add public static final int into BoolErrRecord to 
represent the 7 allowed values. Change the testcase that produces 
testBoolErr.xls. And add a new testcase to verify that invalid arguments to 
HSSFCell.setErrorValue throw an exception.
Comment 4 Avik Sengupta 2003-10-30 18:17:22 UTC
Fixed in Branch. Added check to BoolErrorRecord, to throw RuntimeException, and
updated Testcase. Committed the same changes to HEAD, but the tescase was
already failing in HEAD.