From: Glen Stampoultzis Date: Sun, 21 Sep 2003 09:58:24 +0000 (+0000) Subject: Fixed bug relating to rewriting empty workbooks. The aggregates were not being added... X-Git-Tag: REL_2_5_1~85 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=802f50a7842ff3afb69bb461b0819760f866893b;p=poi.git Fixed bug relating to rewriting empty workbooks. The aggregates were not being added to the records in this case. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_2_BRANCH@353363 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java index 93eb1cd28d..c0f07b829a 100644 --- a/src/java/org/apache/poi/hssf/model/Sheet.java +++ b/src/java/org/apache/poi/hssf/model/Sheet.java @@ -235,9 +235,9 @@ public class Sheet implements Model } else if ( rec.getSid() == RowRecord.sid ) { - RowRecord row = (RowRecord)rec; - if (!isfirstrow) rec = null; //only add the aggregate once - + RowRecord row = (RowRecord)rec; + if (!isfirstrow) rec = null; //only add the aggregate once + if ( isfirstrow ) { retval.rows = new RowRecordsAggregate(); @@ -297,14 +297,16 @@ public class Sheet implements Model } } retval.records = records; - if (retval.rows == null) - { - retval.rows = new RowRecordsAggregate(); - } - if (retval.cells == null) - { - retval.cells = new ValueRecordsAggregate(); - } +// if (retval.rows == null) +// { +// retval.rows = new RowRecordsAggregate(); +// } + retval.checkCells(); + retval.checkRows(); +// if (retval.cells == null) +// { +// retval.cells = new ValueRecordsAggregate(); +// } log.log(log.DEBUG, "sheet createSheet (existing file) exited"); return retval; } @@ -1002,10 +1004,7 @@ public class Sheet implements Model { checkCells(); log.logFormatted(log.DEBUG, "remove value record row,dimsloc %,%", - new int[] - { - row, dimsloc - }); + new int[]{row, dimsloc} ); loc = dimsloc; cells.removeCell(col); diff --git a/src/testcases/org/apache/poi/hssf/data/blankworkbook.xls b/src/testcases/org/apache/poi/hssf/data/blankworkbook.xls new file mode 100644 index 0000000000..fcf734d6a8 Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/blankworkbook.xls differ