Tolerate Double.NaN when reading .xls files, see Bugzilla 49761

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1033004 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2010-11-09 15:02:31 +00:00
parent 3b5f224ccb
commit 9a2fdbd473
3 changed files with 10 additions and 2 deletions

View File

@ -273,7 +273,10 @@ public final class RecordInputStream implements LittleEndianInput {
long valueLongBits = readLong();
double result = Double.longBitsToDouble(valueLongBits);
if (Double.isNaN(result)) {
throw new RuntimeException("Did not expect to read NaN"); // (Because Excel typically doesn't write NaN
// YK: Excel doesn't write NaN but instead converts the cell type into CELL_TYPE_ERROR.
// HSSF prior to version 3.7 had a bug: it could write Double.NaN but could not read such a file back.
// This behavior was fixed in POI-3.7.
//throw new RuntimeException("Did not expect to read NaN"); // (Because Excel typically doesn't write NaN
}
return result;
}

View File

@ -321,5 +321,10 @@ public final class TestHSSFCell extends BaseTestCell {
}
}
/**
* HSSF prior to version 3.7 had a bug: it could write a NaN but could not read such a file back.
*/
public void testReadNaN() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49761.xls");
}
}

Binary file not shown.