<changes>
<release version="3.8-beta4" date="2011-??-??">
+ <action dev="poi-developers" type="fix">51533 - Avoid exception when changing name of a sheet containing shared formulas</action>
<action dev="poi-developers" type="add">Support for appending images to existing drawings in HSSF</action>
<action dev="poi-developers" type="fix">Added initial support for bookmarks in HWFP</action>
<action dev="poi-developers" type="fix">46250 - Fixed cloning worksheets with images</action>
CTCellFormula f = cell.getCTCell().getF();
if (f != null) {
String formula = f.getStringValue();
- if (formula != null) {
+ if (formula != null && formula.length() > 0) {
int sheetIndex = _wb.getSheetIndex(cell.getSheet());
Ptg[] ptgs = FormulaParser.parse(formula, _fpwb, FormulaType.CELL, sheetIndex);
String updatedFormula = FormulaRenderer.toFormulaString(frwb, ptgs);
assertEquals(6.0, evaluator.evaluate(cell2).getNumberValue());
}
+ public void changeSheetNameWithSharedFormulas(String sampleFile){
+ Workbook wb = _testDataProvider.openSampleWorkbook(sampleFile);
+
+ FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
+
+ Sheet sheet = wb.getSheetAt(0);
+
+ for (int rownum = 1; rownum <= 40; rownum++) {
+ Cell cellA = sheet.getRow(1).getCell(0);
+ Cell cellB = sheet.getRow(1).getCell(1);
+
+ assertEquals(cellB.getStringCellValue(), evaluator.evaluate(cellA).getStringValue());
+ }
+
+ wb.setSheetName(0, "Renamed by POI");
+ evaluator.clearAllCachedResultValues();
+
+ for (int rownum = 1; rownum <= 40; rownum++) {
+ Cell cellA = sheet.getRow(1).getCell(0);
+ Cell cellB = sheet.getRow(1).getCell(1);
+
+ assertEquals(cellB.getStringCellValue(), evaluator.evaluate(cellA).getStringValue());
+ }
+ }
}