<changes>
<release version="3.8-beta6" date="2012-??-??">
+ <action dev="poi-developers" type="fix">52527 - avoid exception when matching shared formula records in HSSF</action>
<action dev="poi-developers" type="add">52568 - Added methods to set/get an XWPFRun's text color</action>
<action dev="poi-developers" type="add">52566 - Added methods to set/get vertical alignment and color in XWPFTableCell</action>
<action dev="poi-developers" type="add">52562 - Added methods to get/set a table row's Can't Split and Repeat Header attributes in XWPF</action>
*/
public SharedFormulaRecord linkSharedFormulaRecord(CellReference firstCell, FormulaRecordAggregate agg) {
SharedFormulaGroup result = findFormulaGroupForCell(firstCell);
+ if(null == result) {
+ throw new RuntimeException("Failed to find a matching shared formula record");
+ }
result.add(agg);
return result.getSFR();
}
}
}
SharedFormulaGroup sfg = _groupsCache.get(getKeyForCache(cellRef));
- if(null == sfg) {
- // TODO - fix file "15228.xls" so it opens in Excel after rewriting with POI
- throw new RuntimeException("Failed to find a matching shared formula record");
- }
return sfg;
}
throw new RuntimeException(e);
}
}
+
+ public void testBug52527() {
+ HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("52527.xls");
+ HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
+
+ assertEquals("IF(H3,LINEST(N9:N14,K9:M14,FALSE),LINEST(N8:N14,K8:M14,FALSE))",
+ wb1.getSheetAt(0).getRow(4).getCell(11).getCellFormula());
+ assertEquals("IF(H3,LINEST(N9:N14,K9:M14,FALSE),LINEST(N8:N14,K8:M14,FALSE))",
+ wb2.getSheetAt(0).getRow(4).getCell(11).getCellFormula());
+
+ assertEquals("1/SQRT(J9)",
+ wb1.getSheetAt(0).getRow(8).getCell(10).getCellFormula());
+ assertEquals("1/SQRT(J9)",
+ wb2.getSheetAt(0).getRow(8).getCell(10).getCellFormula());
+
+ assertEquals("1/SQRT(J26)",
+ wb1.getSheetAt(0).getRow(25).getCell(10).getCellFormula());
+ assertEquals("1/SQRT(J26)",
+ wb2.getSheetAt(0).getRow(25).getCell(10).getCellFormula());
+ }
}