diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 736f3549b..81a4a3bea 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 49966 - Correctly remove calcChain entries for XSSF cells that stop holding formulas 47582 - XSSFCellStyle support for creating a style in one workbook based on a style from a different one 49931 - Avoid concurrency problems when re-ordering multiple HSSF header records for a PageSettingsBlock 49765 - Fix XWPFDocument.addPicture so that it correctly sets up relationships diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index 93efe4b37..e0998bc59 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -721,11 +721,15 @@ public final class XSSFCell implements Cell { * @see #CELL_TYPE_ERROR */ public void setCellType(int cellType) { + int prevType = getCellType(); + if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); } - - int prevType = getCellType(); + if(prevType == CELL_TYPE_FORMULA && cellType != CELL_TYPE_FORMULA) { + getSheet().getWorkbook().onDeleteFormula(this); + } + switch (cellType) { case CELL_TYPE_BLANK: setBlank(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 53747f5e3..f61717f47 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -365,9 +365,12 @@ public class XSSFRow implements Row, Comparable { } XSSFCell xcell = (XSSFCell)cell; - if(xcell.isPartOfArrayFormulaGroup()){ + if(xcell.isPartOfArrayFormulaGroup()) { xcell.notifyArrayFormulaChanging(); } + if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) { + _sheet.getWorkbook().onDeleteFormula(xcell); + } _cells.remove(cell.getColumnIndex()); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 8ae7f9a85..00d2ffee7 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -833,7 +833,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable