From: Nick Burch Date: Mon, 10 Nov 2008 12:20:49 +0000 (+0000) Subject: Fix for bug #46137 - continue records after eofrecord X-Git-Tag: REL_3_5_BETA4~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=aceffbe29d34e0efeafeb1f7b56eba1bf5b600a4;p=poi.git Fix for bug #46137 - continue records after eofrecord git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@712652 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 0d04e7ef44..259caeae30 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 46137 - Handle odd files with a ContinueRecord after EOFRecord Fixed problem with linking shared formulas when ranges overlap 45784 - More fixes to SeriesTextRecord 46033 - fixed TableCell to correctly set text type diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 430a136bfb..3cef6f652c 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 46137 - Handle odd files with a ContinueRecord after EOFRecord Fixed problem with linking shared formulas when ranges overlap 45784 - More fixes to SeriesTextRecord 46033 - fixed TableCell to correctly set text type diff --git a/src/java/org/apache/poi/hssf/record/RecordFactory.java b/src/java/org/apache/poi/hssf/record/RecordFactory.java index bae867e512..da8424e466 100644 --- a/src/java/org/apache/poi/hssf/record/RecordFactory.java +++ b/src/java/org/apache/poi/hssf/record/RecordFactory.java @@ -383,6 +383,10 @@ public final class RecordFactory { //Gracefully handle records that we don't know about, //that happen to be continued records.add(record); + } else if (lastRecord instanceof EOFRecord) { + // This is really odd, but excel still sometimes + // outputs a file like this all the same + records.add(record); } else { throw new RecordFormatException("Unhandled Continue Record"); } diff --git a/src/testcases/org/apache/poi/hssf/data/46137.xls b/src/testcases/org/apache/poi/hssf/data/46137.xls new file mode 100644 index 0000000000..5fc399dd62 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/46137.xls differ diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 1f7648ed75..024f94e5b7 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -1523,4 +1523,14 @@ public final class TestBugs extends TestCase { assertEquals(64, green.getCellStyle().getFillBackgroundColor()); assertEquals("0:FFFF:0", p.getColor(11).getHexString()); } + + /** + * ContinueRecord after EOF + */ + public void test46137() { + // This used to break + HSSFWorkbook wb = openSample("46137.xls"); + assertEquals(7, wb.getNumberOfSheets()); + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); + } }