git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1148673 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_8_BETA4
@@ -34,6 +34,7 @@ | |||
<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> |
@@ -120,7 +120,7 @@ public final class XSSFFormulaUtils { | |||
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); |
@@ -428,4 +428,8 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook { | |||
assertFalse(wb.getForceFormulaRecalculation()); | |||
} | |||
public void testChangeSheetNameWithSharedFormulas() { | |||
changeSheetNameWithSharedFormulas("shared_formulas.xlsx"); | |||
} | |||
} |
@@ -713,4 +713,9 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { | |||
assertEquals(3, bse.getRef()); | |||
} | |||
} | |||
public void testChangeSheetNameWithSharedFormulas() { | |||
changeSheetNameWithSharedFormulas("shared_formulas.xls"); | |||
} | |||
} |
@@ -568,4 +568,28 @@ public abstract class BaseTestWorkbook extends TestCase { | |||
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()); | |||
} | |||
} | |||
} |