diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 8341f465a..098244165 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -25,6 +25,8 @@ import org.apache.poi.hssf.model.InternalWorkbook; import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate; import org.apache.poi.hssf.record.common.UnicodeString; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.formula.ptg.Area3DPtg; import org.apache.poi.ss.formula.ptg.DeletedArea3DPtg; import org.apache.poi.ss.formula.ptg.Ptg; @@ -2123,4 +2125,20 @@ if(1==2) { wb = writeOutAndReadBack(wb); assertEquals(1, wb.getNumberOfSheets()); } + + /** + * File with exactly 256 data blocks (+header block) + * shouldn't break on POIFS loading + */ + public void test51461() throws Exception { + byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51461.xls"); + + HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem( + new ByteArrayInputStream(data)).getRoot(), false); + HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new NPOIFSFileSystem( + new ByteArrayInputStream(data)).getRoot(), false); + + assertEquals(2, wbPOIFS.getNumberOfSheets()); + assertEquals(2, wbNPOIFS.getNumberOfSheets()); + } } diff --git a/test-data/spreadsheet/51461.xls b/test-data/spreadsheet/51461.xls new file mode 100644 index 000000000..0f6c1bdfb Binary files /dev/null and b/test-data/spreadsheet/51461.xls differ