mirror of https://github.com/apache/poi.git
#57642 Fix setSheetName with ISERROR on XSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1675745 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9582cdaa31
commit
cc2557adbb
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue