ValueRecordsAggregate vrAgg = (ValueRecordsAggregate)rec;
for (Iterator cellIter = vrAgg.getIterator();cellIter.hasNext();) {
Record valRec = (Record)cellIter.next();
- clonedRecords.add(valRec);
+
+ if (valRec instanceof FormulaRecordAggregate) {
+ FormulaRecordAggregate fmAgg = (FormulaRecordAggregate)valRec;
+ Record fmAggRec = fmAgg.getFormulaRecord();
+ if (fmAggRec != null)
+ clonedRecords.add(fmAggRec);
+ fmAggRec = fmAgg.getStringRecord();
+ if (fmAggRec != null)
+ clonedRecords.add(fmAggRec);
+ } else {
+ clonedRecords.add(valRec);
+ }
}
- } else if (rec instanceof FormulaRecordAggregate) {
+ } else if (rec instanceof FormulaRecordAggregate) { //Is this required now??
FormulaRecordAggregate fmAgg = (FormulaRecordAggregate)rec;
Record fmAggRec = fmAgg.getFormulaRecord();
if (fmAggRec != null)
if(stringRecord==null) return null;
return stringRecord.getString();
}
-
}
assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol());
}
+ /** cell with formula becomes null on cloning a sheet*/
+ public void test35084() {
+
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet s =wb.createSheet("Sheet1");
+ HSSFRow r = s.createRow(0);
+ r.createCell((short)0).setCellValue(1);
+ r.createCell((short)1).setCellFormula("A1*2");
+ HSSFSheet s1 = wb.cloneSheet(0);
+ r=s1.getRow(0);
+ assertEquals("double" ,r.getCell((short)0).getNumericCellValue(),(double)1,0); //sanity check
+ assertNotNull(r.getCell((short)1));
+ assertEquals("formula", r.getCell((short)1).getCellFormula(), "A1*2");
+ }
+
+
public static void main(java.lang.String[] args) {
junit.textui.TestRunner.run(TestHSSFSheet.class);
}
assertTrue("Read book fine!" , true);
}
- /* cell with formula becomes null on cloning a sheet*/
- public void test35084() {
-
- HSSFWorkbook wb = new HSSFWorkbook();
- HSSFSheet s =wb.createSheet("Sheet1");
- HSSFRow r = s.createRow(0);
- r.createCell((short)0).setCellValue(1);
- r.createCell((short)1).setCellFormula("A1*2");
- HSSFSheet s1 = wb.cloneSheet(0);
- r=s1.getRow(0);
- assertEquals("double" ,r.getCell((short)0).getNumericCellValue(),(double)1,0); //sanity check, pass
- assertNotNull(r.getCell((short)1)); //Fails
- assertEquals("formula", r.getCell((short)1).getCellFormula(), "A1*2"); //Fails
-
-
-
- }
}