import org.apache.poi.ss.util.NumberToTextConverter;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LocaleUtil;
+import org.apache.poi.util.Removal;
/**
* High level representation of a cell in a row of a spreadsheet.
/**
* Only valid for formula cells
- *
- * Will return {@link CellType} in a future version of POI.
- * For forwards compatibility, do not hard-code cell type literals in your code.
- *
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
+ *
+ * @since POI 4.0
+ * @return <code>CellType</code> depending
+ * on the cached value of the formula
*/
@Override
- public int getCachedFormulaResultType() {
- return getCachedFormulaResultTypeEnum().getCode();
+ public CellType getCachedFormulaResultType() {
+ if (_cellType != CellType.FORMULA) {
+ throw new IllegalStateException("Only formula cells have cached results");
+ }
+ int code = ((FormulaRecordAggregate)_record).getFormulaRecord().getCachedResultType();
+ return CellType.forInt(code);
}
/**
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
* @since POI 3.15 beta 3
+ * @deprecated use <code>getCachedFormulaResultType</code>
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version="4.2")
@Override
public CellType getCachedFormulaResultTypeEnum() {
- if (_cellType != CellType.FORMULA) {
- throw new IllegalStateException("Only formula cells have cached results");
- }
- int code = ((FormulaRecordAggregate)_record).getFormulaRecord().getCachedResultType();
- return CellType.forInt(code);
+ return getCachedFormulaResultType();
}
void setCellArrayFormula(CellRangeAddress range) {
import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.Removal;
/**
* HSSF wrapper for a cell under evaluation
}
/**
- * Will return {@link CellType} in a future version of POI.
- * For forwards compatibility, do not hard-code cell type literals in your code.
- *
+ * @since POI 4.0
* @return cell type of cached formula result
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Override
- public int getCachedFormulaResultType() {
- return _cell.getCachedFormulaResultType();
- }
+ public CellType getCachedFormulaResultType() { return _cell.getCachedFormulaResultType(); }
+
/**
* @since POI 3.15 beta 3
* @deprecated POI 3.15 beta 3.
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Override
public CellType getCachedFormulaResultTypeEnum() {
- return _cell.getCachedFormulaResultTypeEnum();
+ return getCachedFormulaResultType();
}
}
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.util.Removal;
/**
* Common functionality across file formats for evaluating formula cells.<p>
protected abstract CellValue evaluateFormulaCellValue(Cell cell);
/**
- * If cell contains formula, it evaluates the formula, and saves the result of the formula. The
- * cell remains as a formula cell. If the cell does not contain formula, this method returns -1
- * and leaves the cell unchanged.
- *
- * Note that the type of the <em>formula result</em> is returned, so you know what kind of
- * cached formula result is also stored with the formula.
+ * If cell contains formula, it evaluates the formula,
+ * and saves the result of the formula. The cell
+ * remains as a formula cell.
+ * Else if cell does not contain formula, this method leaves
+ * the cell unchanged.
+ * Note that the type of the formula result is returned,
+ * so you know what kind of value is also stored with
+ * the formula.
* <pre>
- * int evaluatedCellType = evaluator.evaluateFormulaCell(cell);
+ * CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
* </pre>
- * Be aware that your cell will hold both the formula, and the result. If you want the cell
- * replaced with the result of the formula, use {@link #evaluateInCell(org.apache.poi.ss.usermodel.Cell)}
+ * Be aware that your cell will hold both the formula,
+ * and the result. If you want the cell replaced with
+ * the result of the formula, use {@link #evaluate(org.apache.poi.ss.usermodel.Cell)} }
* @param cell The cell to evaluate
- * @return -1 for non-formula cells, or the type of the <em>formula result</em>
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
+ * @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
+ * If cell is not a formula cell, returns {@link CellType#_NONE} rather than throwing an exception.
*/
@Override
- public int evaluateFormulaCell(Cell cell) {
- return evaluateFormulaCellEnum(cell).getCode();
+ public CellType evaluateFormulaCell(Cell cell) {
+ if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
+ return CellType._NONE;
+ }
+ CellValue cv = evaluateFormulaCellValue(cell);
+ // cell remains a formula cell, but the cached value is changed
+ setCellValue(cell, cv);
+ return cv.getCellTypeEnum();
}
/**
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
* If cell is not a formula cell, returns {@link CellType#_NONE} rather than throwing an exception.
* @since POI 3.15 beta 3
+ * @deprecated use <code>evaluateFormulaCell(cell)</code> instead
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Override
public CellType evaluateFormulaCellEnum(Cell cell) {
- if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
- return CellType._NONE;
- }
- CellValue cv = evaluateFormulaCellValue(cell);
- // cell remains a formula cell, but the cached value is changed
- setCellValue(cell, cv);
- return cv.getCellTypeEnum();
+ return evaluateFormulaCell(cell);
}
protected static void setCellType(Cell cell, CellValue cv) {
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.Removal;
/**
* Abstracts a cell for the purpose of formula evaluation. This interface represents both formula
boolean isPartOfArrayFormulaGroup();
/**
- * Will return {@link CellType} in a future version of POI.
- * For forwards compatibility, do not hard-code cell type literals in your code.
- *
* @return cell type of cached formula result
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
- int getCachedFormulaResultType();
+ CellType getCachedFormulaResultType();
/**
* @since POI 3.15 beta 3
* @deprecated POI 3.15 beta 3.
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
CellType getCachedFormulaResultTypeEnum();
}
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.Removal;
/**
return _masterCell.isPartOfArrayFormulaGroup();
}
/**
- * Will return {@link CellType} in a future version of POI.
- * For forwards compatibility, do not hard-code cell type literals in your code.
- *
* @return cell type of cached formula result
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Override
- public int getCachedFormulaResultType() {
+ public CellType getCachedFormulaResultType() {
return _masterCell.getCachedFormulaResultType();
}
+
/**
* @since POI 3.15 beta 3
* @deprecated POI 3.15 beta 3.
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Override
public CellType getCachedFormulaResultTypeEnum() {
- return _masterCell.getCachedFormulaResultTypeEnum();
+ return getCachedFormulaResultType();
}
}
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
- @Deprecated
- int getCachedFormulaResultType();
+ CellType getCachedFormulaResultType();
/**
* Only valid for formula cells
* @since POI 3.15 beta 3
* Will be renamed to <code>getCachedFormulaResultType()</code> when we make the CellType enum transition in POI 4.0. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
CellType getCachedFormulaResultTypeEnum();
/**
package org.apache.poi.ss.usermodel;
+import org.apache.poi.util.Removal;
+
import java.util.Map;
/**
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
* Note: the cell's type remains as CellType.FORMULA however.
- * @deprecated 3.15. Will return a {@link CellType} enum in the future
*/
- int evaluateFormulaCell(Cell cell);
+ CellType evaluateFormulaCell(Cell cell);
/**
* If cell contains formula, it evaluates the formula,
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
* Note: the cell's type remains as CellType.FORMULA however.
+ * @deprecated use <code>evaluateFormulaCell(cell)</code>
*/
+ @Deprecated
+ @Removal(version = "4.2")
CellType evaluateFormulaCellEnum(Cell cell);
/**
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
/**
@Override
public void evaluateAll() {}
@Override
- public int evaluateFormulaCell(Cell cell) {
- //noinspection deprecation
- return cell.getCachedFormulaResultType();
- }
- /**
+ public CellType evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); }
+ /**
* @since POI 3.15 beta 3
* @deprecated POI 3.15 beta 3. Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Internal(since="POI 3.15 beta 3")
@Override
- public CellType evaluateFormulaCellEnum(Cell cell) {
- return cell.getCachedFormulaResultTypeEnum();
- }
+ public CellType evaluateFormulaCellEnum(Cell cell) { return evaluateFormulaCell(cell); }
};
/**
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
-import org.apache.poi.util.LocaleUtil;
-import org.apache.poi.util.NotImplemented;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
+import org.apache.poi.util.*;
import org.apache.poi.xssf.usermodel.XSSFHyperlink;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Override
- public int getCachedFormulaResultType()
- {
- return getCachedFormulaResultTypeEnum().getCode();
+ public CellType getCachedFormulaResultType() {
+ if (_value.getType() != CellType.FORMULA) {
+ throw new IllegalStateException("Only formula cells have cached results");
+ }
+
+ return ((FormulaValue)_value).getFormulaType();
}
/**
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
* @since POI 3.15 beta 3
- * Will be deleted when we make the CellType enum transition. See bug 59791.
+ * @deprecated use <code>getCachedFormulaResultTypeEnum</code> instead
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Override
- public CellType getCachedFormulaResultTypeEnum()
- {
- if (_value.getType() != CellType.FORMULA) {
- throw new IllegalStateException("Only formula cells have cached results");
- }
-
- return ((FormulaValue)_value).getFormulaType();
+ public CellType getCachedFormulaResultTypeEnum() {
+ return getCachedFormulaResultType();
}
/**
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
/**
* SXSSF wrapper for a cell under evaluation
}
/**
- * Will return {@link CellType} in a future version of POI.
- * For forwards compatibility, do not hard-code cell type literals in your code.
- *
* @return cell type of cached formula result
- * @deprecated 3.17. Will return a {@link CellType} enum in the future.
*/
@Override
- public int getCachedFormulaResultType() {
- return _cell.getCachedFormulaResultType();
+ public CellType getCachedFormulaResultType() {
+ return _cell.getCachedFormulaResultTypeEnum();
}
/**
* @since POI 3.15 beta 3
* @deprecated POI 3.15 beta 3.
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Internal(since="POI 3.15 beta 3")
@Override
public CellType getCachedFormulaResultTypeEnum() {
- return _cell.getCachedFormulaResultTypeEnum();
+ return getCachedFormulaResultType();
}
}
/**
* Only valid for formula cells
- *
- * Will return {@link CellType} in a future version of POI.
- * For forwards compatibility, do not hard-code cell type literals in your code.
- *
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
- * @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
- @Deprecated
@Override
- @Removal(version="3.17")
- public int getCachedFormulaResultType() {
- return getCachedFormulaResultTypeEnum().getCode();
+ public CellType getCachedFormulaResultType() {
+ if (! isFormulaCell()) {
+ throw new IllegalStateException("Only formula cells have cached results");
+ }
+
+ return getBaseCellType(false);
}
/**
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
* @since POI 3.15 beta 3
+ * @deprecated use <code>getCachedFormulaResultType</code> instead
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Override
public CellType getCachedFormulaResultTypeEnum() {
- if (! isFormulaCell()) {
- throw new IllegalStateException("Only formula cells have cached results");
- }
-
- return getBaseCellType(false);
+ return getCachedFormulaResultType();
}
/**
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Internal;
+import org.apache.poi.util.Removal;
/**
* XSSF wrapper for a cell under evaluation
}
/**
- * Will return {@link CellType} in a future version of POI.
- * For forwards compatibility, do not hard-code cell type literals in your code.
- *
* @return cell type of cached formula result
- * @deprecated 3.17. Will return a {@link CellType} enum in the future.
*/
@Override
- public int getCachedFormulaResultType() {
- return _cell.getCachedFormulaResultType();
+ public CellType getCachedFormulaResultType() {
+ return _cell.getCachedFormulaResultTypeEnum();
}
/**
* @since POI 3.15 beta 3
* @deprecated POI 3.15 beta 3.
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Internal(since="POI 3.15 beta 3")
@Override
public CellType getCachedFormulaResultTypeEnum() {
- return _cell.getCachedFormulaResultTypeEnum();
+ return getCachedFormulaResultType();
}
}