Change getCachedFormulaResultType to return CellType
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808678 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a51bac65b7
commit
16d262d0b4
@ -55,6 +55,7 @@ import org.apache.poi.ss.util.CellReference;
|
|||||||
import org.apache.poi.ss.util.NumberToTextConverter;
|
import org.apache.poi.ss.util.NumberToTextConverter;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
import org.apache.poi.util.LocaleUtil;
|
import org.apache.poi.util.LocaleUtil;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* High level representation of a cell in a row of a spreadsheet.
|
* High level representation of a cell in a row of a spreadsheet.
|
||||||
@ -1145,18 +1146,21 @@ public class HSSFCell implements Cell {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Only valid for formula cells
|
* 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},
|
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||||
* on the cached value of the formula
|
* 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
|
@Override
|
||||||
public int getCachedFormulaResultType() {
|
public CellType getCachedFormulaResultType() {
|
||||||
return getCachedFormulaResultTypeEnum().getCode();
|
if (_cellType != CellType.FORMULA) {
|
||||||
|
throw new IllegalStateException("Only formula cells have cached results");
|
||||||
|
}
|
||||||
|
int code = ((FormulaRecordAggregate)_record).getFormulaRecord().getCachedResultType();
|
||||||
|
return CellType.forInt(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1165,15 +1169,14 @@ public class HSSFCell implements Cell {
|
|||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||||
* on the cached value of the formula
|
* on the cached value of the formula
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
|
* @deprecated use <code>getCachedFormulaResultType</code>
|
||||||
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Removal(version="4.2")
|
||||||
@Override
|
@Override
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
if (_cellType != CellType.FORMULA) {
|
return getCachedFormulaResultType();
|
||||||
throw new IllegalStateException("Only formula cells have cached results");
|
|
||||||
}
|
|
||||||
int code = ((FormulaRecordAggregate)_record).getFormulaRecord().getCachedResultType();
|
|
||||||
return CellType.forInt(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCellArrayFormula(CellRangeAddress range) {
|
void setCellArrayFormula(CellRangeAddress range) {
|
||||||
|
@ -21,6 +21,7 @@ import org.apache.poi.ss.formula.EvaluationCell;
|
|||||||
import org.apache.poi.ss.formula.EvaluationSheet;
|
import org.apache.poi.ss.formula.EvaluationSheet;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HSSF wrapper for a cell under evaluation
|
* HSSF wrapper for a cell under evaluation
|
||||||
@ -107,23 +108,21 @@ final class HSSFEvaluationCell implements EvaluationCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will return {@link CellType} in a future version of POI.
|
* @since POI 4.0
|
||||||
* For forwards compatibility, do not hard-code cell type literals in your code.
|
|
||||||
*
|
|
||||||
* @return cell type of cached formula result
|
* @return cell type of cached formula result
|
||||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getCachedFormulaResultType() {
|
public CellType getCachedFormulaResultType() { return _cell.getCachedFormulaResultType(); }
|
||||||
return _cell.getCachedFormulaResultType();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
* @deprecated POI 3.15 beta 3.
|
* @deprecated POI 3.15 beta 3.
|
||||||
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Removal(version = "4.2")
|
||||||
@Override
|
@Override
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
return _cell.getCachedFormulaResultTypeEnum();
|
return getCachedFormulaResultType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import org.apache.poi.ss.usermodel.RichTextString;
|
|||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common functionality across file formats for evaluating formula cells.<p>
|
* Common functionality across file formats for evaluating formula cells.<p>
|
||||||
@ -143,24 +144,33 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
protected abstract CellValue evaluateFormulaCellValue(Cell cell);
|
protected abstract CellValue evaluateFormulaCellValue(Cell cell);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If cell contains formula, it evaluates the formula, and saves the result of the formula. The
|
* If cell contains formula, it evaluates the formula,
|
||||||
* cell remains as a formula cell. If the cell does not contain formula, this method returns -1
|
* and saves the result of the formula. The cell
|
||||||
* and leaves the cell unchanged.
|
* remains as a formula cell.
|
||||||
*
|
* Else if cell does not contain formula, this method leaves
|
||||||
* Note that the type of the <em>formula result</em> is returned, so you know what kind of
|
* the cell unchanged.
|
||||||
* cached formula result is also stored with the formula.
|
* Note that the type of the formula result is returned,
|
||||||
|
* so you know what kind of value is also stored with
|
||||||
|
* the formula.
|
||||||
* <pre>
|
* <pre>
|
||||||
* int evaluatedCellType = evaluator.evaluateFormulaCell(cell);
|
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
|
||||||
* </pre>
|
* </pre>
|
||||||
* Be aware that your cell will hold both the formula, and the result. If you want the cell
|
* Be aware that your cell will hold both the formula,
|
||||||
* replaced with the result of the formula, use {@link #evaluateInCell(org.apache.poi.ss.usermodel.Cell)}
|
* 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
|
* @param cell The cell to evaluate
|
||||||
* @return -1 for non-formula cells, or the type of the <em>formula result</em>
|
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
|
||||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
|
* If cell is not a formula cell, returns {@link CellType#_NONE} rather than throwing an exception.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int evaluateFormulaCell(Cell cell) {
|
public CellType evaluateFormulaCell(Cell cell) {
|
||||||
return evaluateFormulaCellEnum(cell).getCode();
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,16 +192,13 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
|
* @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.
|
* If cell is not a formula cell, returns {@link CellType#_NONE} rather than throwing an exception.
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
|
* @deprecated use <code>evaluateFormulaCell(cell)</code> instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Removal(version = "4.2")
|
||||||
@Override
|
@Override
|
||||||
public CellType evaluateFormulaCellEnum(Cell cell) {
|
public CellType evaluateFormulaCellEnum(Cell cell) {
|
||||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
return evaluateFormulaCell(cell);
|
||||||
return CellType._NONE;
|
|
||||||
}
|
|
||||||
CellValue cv = evaluateFormulaCellValue(cell);
|
|
||||||
// cell remains a formula cell, but the cached value is changed
|
|
||||||
setCellValue(cell, cv);
|
|
||||||
return cv.getCellTypeEnum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void setCellType(Cell cell, CellValue cv) {
|
protected static void setCellType(Cell cell, CellValue cv) {
|
||||||
|
@ -19,6 +19,7 @@ package org.apache.poi.ss.formula;
|
|||||||
|
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
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
|
* Abstracts a cell for the purpose of formula evaluation. This interface represents both formula
|
||||||
@ -61,17 +62,15 @@ public interface EvaluationCell {
|
|||||||
boolean isPartOfArrayFormulaGroup();
|
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
|
* @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
|
* @since POI 3.15 beta 3
|
||||||
* @deprecated POI 3.15 beta 3.
|
* @deprecated POI 3.15 beta 3.
|
||||||
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Removal(version = "4.2")
|
||||||
CellType getCachedFormulaResultTypeEnum();
|
CellType getCachedFormulaResultTypeEnum();
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import org.apache.poi.ss.formula.eval.ValueEval;
|
|||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,24 +168,23 @@ final class ForkedEvaluationCell implements EvaluationCell {
|
|||||||
return _masterCell.isPartOfArrayFormulaGroup();
|
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
|
* @return cell type of cached formula result
|
||||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getCachedFormulaResultType() {
|
public CellType getCachedFormulaResultType() {
|
||||||
return _masterCell.getCachedFormulaResultType();
|
return _masterCell.getCachedFormulaResultType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
* @deprecated POI 3.15 beta 3.
|
* @deprecated POI 3.15 beta 3.
|
||||||
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Removal(version = "4.2")
|
||||||
@Override
|
@Override
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
return _masterCell.getCachedFormulaResultTypeEnum();
|
return getCachedFormulaResultType();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -198,10 +198,8 @@ public interface Cell {
|
|||||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||||
* on the cached value of the formula
|
* on the cached value of the formula
|
||||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
CellType getCachedFormulaResultType();
|
||||||
int getCachedFormulaResultType();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only valid for formula cells
|
* Only valid for formula cells
|
||||||
@ -211,6 +209,8 @@ public interface Cell {
|
|||||||
* @since POI 3.15 beta 3
|
* @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.
|
* 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();
|
CellType getCachedFormulaResultTypeEnum();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package org.apache.poi.ss.usermodel;
|
package org.apache.poi.ss.usermodel;
|
||||||
|
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,9 +101,8 @@ public interface FormulaEvaluator {
|
|||||||
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
|
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
|
||||||
* Note: the cell's type remains as CellType.FORMULA however.
|
* 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,
|
* If cell contains formula, it evaluates the formula,
|
||||||
@ -123,7 +124,10 @@ public interface FormulaEvaluator {
|
|||||||
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
|
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
|
||||||
* Note: the cell's type remains as CellType.FORMULA however.
|
* 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);
|
CellType evaluateFormulaCellEnum(Cell cell);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,6 +38,7 @@ import org.apache.poi.ss.usermodel.Row;
|
|||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,19 +91,16 @@ public class SheetUtil {
|
|||||||
@Override
|
@Override
|
||||||
public void evaluateAll() {}
|
public void evaluateAll() {}
|
||||||
@Override
|
@Override
|
||||||
public int evaluateFormulaCell(Cell cell) {
|
public CellType evaluateFormulaCell(Cell cell) { return cell.getCachedFormulaResultType(); }
|
||||||
//noinspection deprecation
|
/**
|
||||||
return cell.getCachedFormulaResultType();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @since POI 3.15 beta 3
|
* @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 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")
|
@Internal(since="POI 3.15 beta 3")
|
||||||
@Override
|
@Override
|
||||||
public CellType evaluateFormulaCellEnum(Cell cell) {
|
public CellType evaluateFormulaCellEnum(Cell cell) { return evaluateFormulaCell(cell); }
|
||||||
return cell.getCachedFormulaResultTypeEnum();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,10 +38,7 @@ import org.apache.poi.ss.usermodel.Row;
|
|||||||
import org.apache.poi.ss.util.CellAddress;
|
import org.apache.poi.ss.util.CellAddress;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.ss.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
import org.apache.poi.util.LocaleUtil;
|
import org.apache.poi.util.*;
|
||||||
import org.apache.poi.util.NotImplemented;
|
|
||||||
import org.apache.poi.util.POILogFactory;
|
|
||||||
import org.apache.poi.util.POILogger;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFHyperlink;
|
import org.apache.poi.xssf.usermodel.XSSFHyperlink;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||||
|
|
||||||
@ -175,12 +172,14 @@ public class SXSSFCell implements Cell {
|
|||||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||||
* on the cached value of the formula
|
* on the cached value of the formula
|
||||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getCachedFormulaResultType()
|
public CellType getCachedFormulaResultType() {
|
||||||
{
|
if (_value.getType() != CellType.FORMULA) {
|
||||||
return getCachedFormulaResultTypeEnum().getCode();
|
throw new IllegalStateException("Only formula cells have cached results");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((FormulaValue)_value).getFormulaType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,16 +188,13 @@ public class SXSSFCell implements Cell {
|
|||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||||
* on the cached value of the formula
|
* on the cached value of the formula
|
||||||
* @since POI 3.15 beta 3
|
* @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
|
@Override
|
||||||
public CellType getCachedFormulaResultTypeEnum()
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
{
|
return getCachedFormulaResultType();
|
||||||
if (_value.getType() != CellType.FORMULA) {
|
|
||||||
throw new IllegalStateException("Only formula cells have cached results");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((FormulaValue)_value).getFormulaType();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ import org.apache.poi.ss.formula.EvaluationSheet;
|
|||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SXSSF wrapper for a cell under evaluation
|
* SXSSF wrapper for a cell under evaluation
|
||||||
@ -110,24 +111,22 @@ final class SXSSFEvaluationCell implements EvaluationCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @return cell type of cached formula result
|
||||||
* @deprecated 3.17. Will return a {@link CellType} enum in the future.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getCachedFormulaResultType() {
|
public CellType getCachedFormulaResultType() {
|
||||||
return _cell.getCachedFormulaResultType();
|
return _cell.getCachedFormulaResultTypeEnum();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
* @deprecated POI 3.15 beta 3.
|
* @deprecated POI 3.15 beta 3.
|
||||||
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
* 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")
|
@Internal(since="POI 3.15 beta 3")
|
||||||
@Override
|
@Override
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
return _cell.getCachedFormulaResultTypeEnum();
|
return getCachedFormulaResultType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -714,20 +714,17 @@ public final class XSSFCell implements Cell {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Only valid for formula cells
|
* 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},
|
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||||
* on the cached value of the formula
|
* on the cached value of the formula
|
||||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
@Override
|
@Override
|
||||||
@Removal(version="3.17")
|
public CellType getCachedFormulaResultType() {
|
||||||
public int getCachedFormulaResultType() {
|
if (! isFormulaCell()) {
|
||||||
return getCachedFormulaResultTypeEnum().getCode();
|
throw new IllegalStateException("Only formula cells have cached results");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getBaseCellType(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -736,15 +733,14 @@ public final class XSSFCell implements Cell {
|
|||||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
|
||||||
* on the cached value of the formula
|
* on the cached value of the formula
|
||||||
* @since POI 3.15 beta 3
|
* @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.
|
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Removal(version = "4.2")
|
||||||
@Override
|
@Override
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
if (! isFormulaCell()) {
|
return getCachedFormulaResultType();
|
||||||
throw new IllegalStateException("Only formula cells have cached results");
|
|
||||||
}
|
|
||||||
|
|
||||||
return getBaseCellType(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ import org.apache.poi.ss.formula.EvaluationSheet;
|
|||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.CellType;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
|
import org.apache.poi.util.Removal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XSSF wrapper for a cell under evaluation
|
* XSSF wrapper for a cell under evaluation
|
||||||
@ -110,24 +111,22 @@ final class XSSFEvaluationCell implements EvaluationCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @return cell type of cached formula result
|
||||||
* @deprecated 3.17. Will return a {@link CellType} enum in the future.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getCachedFormulaResultType() {
|
public CellType getCachedFormulaResultType() {
|
||||||
return _cell.getCachedFormulaResultType();
|
return _cell.getCachedFormulaResultTypeEnum();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
* @deprecated POI 3.15 beta 3.
|
* @deprecated POI 3.15 beta 3.
|
||||||
* Will be deleted when we make the CellType enum transition. See bug 59791.
|
* 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")
|
@Internal(since="POI 3.15 beta 3")
|
||||||
@Override
|
@Override
|
||||||
public CellType getCachedFormulaResultTypeEnum() {
|
public CellType getCachedFormulaResultTypeEnum() {
|
||||||
return _cell.getCachedFormulaResultTypeEnum();
|
return getCachedFormulaResultType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user