]> source.dussan.org Git - poi.git/commitdiff
Made sure all row records for the sheet are aggregated since rows are skipped
authorDanny Mui <dmui@apache.org>
Fri, 9 May 2003 12:39:08 +0000 (12:39 +0000)
committerDanny Mui <dmui@apache.org>
Fri, 9 May 2003 12:39:08 +0000 (12:39 +0000)
if a formula yields a String.
PR: 15062

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353095 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/model/Sheet.java
src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java
src/testcases/org/apache/poi/hssf/model/SheetTest.java

index 3a732c4f28140283b001877d175c67e1467d98c1..9a7abadc3fa703faa16d08923868357eff02e64c 100644 (file)
@@ -234,17 +234,16 @@ public class Sheet implements Model
             }
             else if ( rec.getSid() == RowRecord.sid )
             {
+                RowRecord row = (RowRecord)rec;
+                if (!isfirstrow) rec = null; //only add the aggregate once
+                
                 if ( isfirstrow )
                 {
                     retval.rows = new RowRecordsAggregate();
-                    rec = retval.rows;
-                    retval.rows.construct( k, recs );
+                    rec = retval.rows;                    
                     isfirstrow = false;
                 }
-                else
-                {
-                    rec = null;
-                }
+                retval.rows.insertRow(row);
             }
             else if ( rec.getSid() == PrintGridlinesRecord.sid )
             {
index c6347eb0e3731ffc87d64a2d9cd951e476231402..2fe2ef631f2c7803beeb1507957f9aa23d7a60d7 100644 (file)
@@ -135,6 +135,9 @@ public class RowRecordsAggregate
         return lastrow;
     }
 
+       /*
+        * No need to go through all the records as we're just collecting RowRecords 
+
     public int construct(int offset, List records)
     {
         int k = 0;
@@ -154,7 +157,7 @@ public class RowRecordsAggregate
         }
         return k;
     }
-
+       */
     /**
      * called by the class that is responsible for writing this sucker.
      * Subclasses should implement this so that their data is passed back in a
index e10ea4109dba80fc02c622f7bf3e5ac3555647c1..9a78fd63c9c59a11c4468f531374b52c95ed0d81 100644 (file)
@@ -7,6 +7,8 @@ import java.util.List;
 import junit.framework.TestCase;
 
 import org.apache.poi.hssf.record.ColumnInfoRecord;
+import org.apache.poi.hssf.record.RowRecord;
+import org.apache.poi.hssf.record.StringRecord;
 
 /**
  * @author Tony Poppleton
@@ -119,6 +121,39 @@ public class SheetTest extends TestCase
 
        }
 
+       /**
+        * Makes sure all rows registered for this sheet are aggregated, they were being skipped
+        *
+        */
+       public void testRowAggregation() {
+               List records = new ArrayList();
+               RowRecord row = new RowRecord();
+               row.setRowNumber(0);            
+               records.add(row);
+               
+               row = new RowRecord();
+               row.setRowNumber(1);
+               records.add(row);
+
+               records.add(new StringRecord());
+               
+               row = new RowRecord();
+               row.setRowNumber(2);
+               records.add(row);
+               
+               
+               Sheet sheet = Sheet.createSheet(records, 0);
+               assertNotNull("Row [2] was skipped", sheet.getRow(2));
+               
+       }
+
+
+       public static void main(String [] args) {
+               System.out
+               .println("Testing : "+SheetTest.class.getName());
+               junit.textui.TestRunner.run(SheetTest.class);
+  }
+
 }