aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-04-24 02:13:07 +0000
committerNick Burch <nick@apache.org>2015-04-24 02:13:07 +0000
commitcc2557adbb2f348a131963044784a42db3c848c0 (patch)
tree92ca942366c35fa34877e0bf3d35147d3822d1c3 /src
parent9582cdaa31208d5a74a90d69993707a03008c81c (diff)
downloadpoi-cc2557adbb2f348a131963044784a42db3c848c0.tar.gz
poi-cc2557adbb2f348a131963044784a42db3c848c0.zip
#57642 Fix setSheetName with ISERROR on XSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1675745 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java11
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java16
2 files changed, 26 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
index 776210de38..a9d995fb72 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java
@@ -24,6 +24,7 @@ import org.apache.poi.ss.formula.FormulaRenderer;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.formula.ptg.Pxg;
+import org.apache.poi.ss.formula.ptg.Pxg3D;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
@@ -125,9 +126,17 @@ public final class XSSFFormulaUtils {
if (ptg instanceof Pxg) {
Pxg pxg = (Pxg)ptg;
if (pxg.getExternalWorkbookNumber() < 1) {
- if (pxg.getSheetName().equals(oldName)) {
+ if (pxg.getSheetName() != null &&
+ pxg.getSheetName().equals(oldName)) {
pxg.setSheetName(newName);
}
+ if (pxg instanceof Pxg3D) {
+ Pxg3D pxg3D = (Pxg3D)pxg;
+ if (pxg3D.getLastSheetName() != null &&
+ pxg3D.getLastSheetName().equals(oldName)) {
+ pxg3D.setLastSheetName(newName);
+ }
+ }
}
}
}
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
index 6a3ddafa3d..6a09b9033d 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
@@ -2367,4 +2367,20 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertNotNull(bgColor);
assertEquals("FF00FFFF", fgColor.getARGBHex());
}
+
+ @Test
+ public void bug57642() throws Exception {
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet s = wb.createSheet("TestSheet");
+ XSSFCell c = s.createRow(0).createCell(0);
+ c.setCellFormula("ISERROR(TestSheet!A1)");
+ c = s.createRow(1).createCell(1);
+ c.setCellFormula("ISERROR(B2)");
+
+ wb.setSheetName(0, "CSN");
+ c = s.getRow(0).getCell(0);
+ assertEquals("ISERROR(CSN!A1)", c.getCellFormula());
+ c = s.getRow(1).getCell(1);
+ assertEquals("ISERROR(B2)", c.getCellFormula());
+ }
}