update getCellType to return CellType enum instead of int

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808700 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2017-09-18 13:26:16 +00:00
parent d9b63eb569
commit d4486af6de
26 changed files with 237 additions and 438 deletions

View File

@ -321,7 +321,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
// Only output if requested
outputContents = _includeBlankCells;
} else {
switch(cell.getCellTypeEnum()) {
switch(cell.getCellType()) {
case STRING:
text.append(cell.getRichStringCellValue().getString());
break;
@ -338,7 +338,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
if(!_shouldEvaluateFormulas) {
text.append(cell.getCellFormula());
} else {
switch(cell.getCachedFormulaResultTypeEnum()) {
switch(cell.getCachedFormulaResultType()) {
case STRING:
HSSFRichTextString str = cell.getRichStringCellValue();
if(str != null && str.length() > 0) {
@ -359,13 +359,13 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p
text.append(ErrorEval.getText(cell.getErrorCellValue()));
break;
default:
throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultTypeEnum());
throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultType());
}
}
break;
default:
throw new RuntimeException("Unexpected cell type (" + cell.getCellTypeEnum() + ")");
throw new RuntimeException("Unexpected cell type (" + cell.getCellType() + ")");
}
// Output the comment, if requested and exists

View File

@ -256,22 +256,6 @@ public class HSSFCell implements Cell {
return new CellAddress(this);
}
/**
* Set the cells type (numeric, formula or string).
* If the cell currently contains a value, the value will
* be converted to match the new type, if possible.
* @see CellType#NUMERIC
* @see CellType#STRING
* @see CellType#FORMULA
* @see CellType#BLANK
* @see CellType#BOOLEAN
* @see CellType#ERROR
* @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead.
*/
@Override
public void setCellType(int cellType) {
setCellType(CellType.forInt(cellType));
}
/**
* Set the cells type (numeric, formula or string).
* If the cell currently contains a value, the value will
@ -444,26 +428,23 @@ public class HSSFCell implements Cell {
/**
* get the cells type (numeric, formula or string)
*
* Will return {@link CellType} in a future version of POI.
* For forwards compatibility, do not hard-code cell type literals in your code.
* @deprecated 3.15. Will be return a {@link CellType} enum in the future.
*/
@Override
public int getCellType()
public CellType getCellType()
{
return getCellTypeEnum().getCode();
return _cellType;
}
/**
* get the cells type (numeric, formula or string)
* @since 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 getCellTypeEnum()
{
return _cellType;
return getCellType();
}
/**
@ -1227,7 +1208,6 @@ public class HSSFCell implements Cell {
* The purpose of this method is to validate the cell state prior to modification.
* </p>
*
* @see #setCellType(int)
* @see #setCellFormula(String)
* @see HSSFRow#removeCell(org.apache.poi.ss.usermodel.Cell)
* @see org.apache.poi.hssf.usermodel.HSSFSheet#removeRow(org.apache.poi.ss.usermodel.Row)

View File

@ -53,24 +53,21 @@ final class HSSFEvaluationCell implements EvaluationCell {
return _cell.getBooleanCellValue();
}
/**
* 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
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Override
public int getCellType() {
public CellType getCellType() {
return _cell.getCellType();
}
/**
* @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 getCellTypeEnum() {
return _cell.getCellTypeEnum();
return getCellType();
}
@Override
public int getColumnIndex() {

View File

@ -435,8 +435,8 @@ public class CellFormat {
/**
* Returns the ultimate cell type, following the results of formulas. If
* the cell is a {@link CellType#FORMULA}, this returns the result of
* {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the
* result of {@link Cell#getCellTypeEnum()}.
* {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the
* result of {@link Cell#getCellType()}.
*
* Will return {@link CellType} in a future version of POI.
* For forwards compatibility, do not hard-code cell type literals in your code.
@ -453,8 +453,8 @@ public class CellFormat {
/**
* Returns the ultimate cell type, following the results of formulas. If
* the cell is a {@link CellType#FORMULA}, this returns the result of
* {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the
* result of {@link Cell#getCellTypeEnum()}.
* {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the
* result of {@link Cell#getCellType()}.
*
* @param cell The cell.
*
@ -464,9 +464,9 @@ public class CellFormat {
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
public static CellType ultimateTypeEnum(Cell cell) {
CellType type = cell.getCellTypeEnum();
CellType type = cell.getCellType();
if (type == CellType.FORMULA)
return cell.getCachedFormulaResultTypeEnum();
return cell.getCachedFormulaResultType();
else
return type;
}

View File

@ -39,19 +39,13 @@ public interface EvaluationCell {
EvaluationSheet getSheet();
int getRowIndex();
int getColumnIndex();
/**
* 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
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
int getCellType();
CellType getCellType();
/**
* @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 getCellTypeEnum();
double getNumericCellValue();

View File

@ -623,12 +623,12 @@ public class EvaluationConditionalFormatRule implements Comparable<EvaluationCon
private ValueAndFormat getCellValue(Cell cell) {
if (cell != null) {
final CellType type = cell.getCellTypeEnum();
if (type == CellType.NUMERIC || (type == CellType.FORMULA && cell.getCachedFormulaResultTypeEnum() == CellType.NUMERIC) ) {
final CellType type = cell.getCellType();
if (type == CellType.NUMERIC || (type == CellType.FORMULA && cell.getCachedFormulaResultType() == CellType.NUMERIC) ) {
return new ValueAndFormat(new Double(cell.getNumericCellValue()), cell.getCellStyle().getDataFormatString());
} else if (type == CellType.STRING || (type == CellType.FORMULA && cell.getCachedFormulaResultTypeEnum() == CellType.STRING) ) {
} else if (type == CellType.STRING || (type == CellType.FORMULA && cell.getCachedFormulaResultType() == CellType.STRING) ) {
return new ValueAndFormat(cell.getStringCellValue(), cell.getCellStyle().getDataFormatString());
} else if (type == CellType.BOOLEAN || (type == CellType.FORMULA && cell.getCachedFormulaResultTypeEnum() == CellType.BOOLEAN) ) {
} else if (type == CellType.BOOLEAN || (type == CellType.FORMULA && cell.getCachedFormulaResultType() == CellType.BOOLEAN) ) {
return new ValueAndFormat(cell.getStringCellValue(), cell.getCellStyle().getDataFormatString());
}
}

View File

@ -105,25 +105,21 @@ final class ForkedEvaluationCell implements EvaluationCell {
throw new RuntimeException("Wrong data type (" + _cellType + ")");
}
}
/**
* 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
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Override
public int getCellType() {
return _cellType.getCode();
public CellType getCellType() {
return _cellType;
}
/**
* @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 getCellTypeEnum() {
return _cellType;
return getCellType();
}
@Override
public boolean getBooleanCellValue() {

View File

@ -41,66 +41,6 @@ import org.apache.poi.util.Removal;
*/
public interface Cell {
/**
* Numeric Cell type (0)
* @see #setCellType(int)
* @see #getCellType()
* @deprecated POI 3.15 beta 3. Use {@link CellType#NUMERIC} instead.
*/
@Deprecated
@Removal(version="4.0")
int CELL_TYPE_NUMERIC = 0; //CellType.NUMERIC.getCode();
/**
* String Cell type (1)
* @see #setCellType(int)
* @see #getCellType()
* @deprecated POI 3.15 beta 3. Use {@link CellType#STRING} instead.
*/
@Deprecated
@Removal(version="4.0")
int CELL_TYPE_STRING = 1; //CellType.STRING.getCode();
/**
* Formula Cell type (2)
* @see #setCellType(int)
* @see #getCellType()
* @deprecated POI 3.15 beta 3. Use {@link CellType#FORMULA} instead.
*/
@Deprecated
@Removal(version="4.0")
int CELL_TYPE_FORMULA = 2; //CellType.FORMULA.getCode();
/**
* Blank Cell type (3)
* @see #setCellType(int)
* @see #getCellType()
* @deprecated POI 3.15 beta 3. Use {@link CellType#BLANK} instead.
*/
@Deprecated
@Removal(version="4.0")
int CELL_TYPE_BLANK = 3; //CellType.BLANK.getCode();
/**
* Boolean Cell type (4)
* @see #setCellType(int)
* @see #getCellType()
* @deprecated POI 3.15 beta 3. Use {@link CellType#BOOLEAN} instead.
*/
@Deprecated
@Removal(version="4.0")
int CELL_TYPE_BOOLEAN = 4; //CellType.BOOLEAN.getCode();
/**
* Error Cell type (5)
* @see #setCellType(int)
* @see #getCellType()
* @deprecated POI 3.15 beta 3. Use {@link CellType#ERROR} instead.
*/
@Deprecated
@Removal(version="4.0")
int CELL_TYPE_ERROR = 5; //CellType.ERROR.getCode();
/**
* Returns column index of this cell
*
@ -129,29 +69,6 @@ public interface Cell {
*/
Row getRow();
/**
* Set the cells type (numeric, formula or string).
* <p>If the cell currently contains a value, the value will
* be converted to match the new type, if possible. Formatting
* is generally lost in the process however.</p>
* <p>If what you want to do is get a String value for your
* numeric cell, <i>stop!</i>. This is not the way to do it.
* Instead, for fetching the string value of a numeric or boolean
* or date cell, use {@link DataFormatter} instead.</p>
*
* @throws IllegalArgumentException if the specified cell type is invalid
* @throws IllegalStateException if the current value cannot be converted to the new type
* @see CellType#NUMERIC
* @see CellType#STRING
* @see CellType#FORMULA
* @see CellType#BLANK
* @see CellType#BOOLEAN
* @see CellType#ERROR
* @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead.
*/
@Deprecated
@Removal(version="4.0")
void setCellType(int cellType);
/**
* Set the cells type (numeric, formula or string).
* <p>If the cell currently contains a value, the value will
@ -170,14 +87,9 @@ public interface Cell {
/**
* Return the cell type.
*
* Will return {@link CellType} in version 4.0 of POI.
* For forwards compatibility, do not hard-code cell type literals in your code.
*
* @return the cell type
* @deprecated POI 3.15. Will return a {@link CellType} enum in the future.
*/
@Deprecated
int getCellType();
CellType getCellType();
/**
* Return the cell type.
@ -186,6 +98,7 @@ public interface Cell {
* @since POI 3.15 beta 3
* Will be renamed to <code>getCellType()</code> when we make the CellType enum transition in POI 4.0. See bug 59791.
*/
@Deprecated
@Removal(version="4.2")
CellType getCellTypeEnum();

View File

@ -88,26 +88,19 @@ public final class CellValue {
*
* @return the cell type
* @since POI 3.15
* Will be renamed to <code>getCellTypeEnum()</code> when we make the CellType enum transition in POI 4.0. See bug 59791.
* @deprecated use <code>getCellType</code> instead
*/
@Deprecated
@Removal(version="4.2")
public CellType getCellTypeEnum() {
return _cellType;
}
public CellType getCellTypeEnum() { return getCellType(); }
/**
* Return the cell type.
*
* Will return {@link CellType} in version 4.0 of POI.
* For forwards compatibility, do not hard-code cell type literals in your code.
*
* @return the cell type
*
* @deprecated POI 3.15. Use {@link #getCellTypeEnum()} instead.
*/
@Deprecated
public int getCellType() {
return _cellType.getCode();
public CellType getCellType() {
return _cellType;
}
/**

View File

@ -162,19 +162,19 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor
Cell cell = ri.next();
// Is it a formula one?
if(cell.getCellTypeEnum() == CellType.FORMULA) {
if(cell.getCellType() == CellType.FORMULA) {
if (formulasNotResults) {
String contents = cell.getCellFormula();
checkMaxTextSize(text, contents);
text.append(contents);
} else {
if (cell.getCachedFormulaResultTypeEnum() == CellType.STRING) {
if (cell.getCachedFormulaResultType() == CellType.STRING) {
handleStringCell(text, cell);
} else {
handleNonStringCell(text, cell, formatter);
}
}
} else if(cell.getCellTypeEnum() == CellType.STRING) {
} else if(cell.getCellType() == CellType.STRING) {
handleStringCell(text, cell);
} else {
handleNonStringCell(text, cell, formatter);
@ -236,9 +236,9 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor
}
private void handleNonStringCell(StringBuffer text, Cell cell, DataFormatter formatter) {
CellType type = cell.getCellTypeEnum();
CellType type = cell.getCellType();
if (type == CellType.FORMULA) {
type = cell.getCachedFormulaResultTypeEnum();
type = cell.getCachedFormulaResultType();
}
if (type == CellType.NUMERIC) {

View File

@ -113,24 +113,6 @@ public class SXSSFCell implements Cell {
return _row;
}
/**
* Set the cells type (numeric, formula or string)
*
* @throws IllegalArgumentException if the specified cell type is invalid
* @see CellType#NUMERIC
* @see CellType#STRING
* @see CellType#FORMULA
* @see CellType#BLANK
* @see CellType#BOOLEAN
* @see CellType#ERROR
* @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead.
* Will be deleted when we make the CellType enum transition. See bug 59791.
*/
@Override
public void setCellType(int cellType)
{
ensureType(CellType.forInt(cellType));
}
/**
* Set the cells type (numeric, formula or string)
*
@ -146,12 +128,11 @@ public class SXSSFCell implements Cell {
* Return the cell type.
*
* @return the cell type
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Override
public int getCellType()
public CellType getCellType()
{
return getCellTypeEnum().getCode();
return _value.getType();
}
/**
@ -159,12 +140,14 @@ public class SXSSFCell implements Cell {
*
* @return the cell type
* @since POI 3.15 beta 3
* Will be deleted when we make the CellType enum transition. See bug 59791.
* @deprecated use <code>getCellType</code> instead
*/
@Deprecated
@Removal(version = "4.2")
@Override
public CellType getCellTypeEnum()
{
return _value.getType();
return getCellType();
}
/**
@ -188,7 +171,7 @@ public class SXSSFCell implements Cell {
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
* on the cached value of the formula
* @since POI 3.15 beta 3
* @deprecated use <code>getCachedFormulaResultTypeEnum</code> instead
* @deprecated use <code>getCachedFormulaResultType</code> instead
*/
@Deprecated
@Removal(version = "4.2")
@ -999,7 +982,7 @@ public class SXSSFCell implements Cell {
CellType cellType = getCellTypeEnum();
if (cellType == CellType.FORMULA) {
cellType = getCachedFormulaResultTypeEnum();
cellType = getCachedFormulaResultType();
}
switch (cellType) {

View File

@ -55,21 +55,19 @@ final class SXSSFEvaluationCell implements EvaluationCell {
return _cell.getBooleanCellValue();
}
/**
* 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
* @deprecated 3.17. Will return a {@link CellType} enum in the future.
*/
@Override
public int getCellType() {
public CellType getCellType() {
return _cell.getCellType();
}
/**
* @since POI 3.15 beta 3
* @deprecated POI 3.15 beta 3.
* @deprecated use <code>getCellType</code> instead
* 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 getCellTypeEnum() {
@ -115,7 +113,7 @@ final class SXSSFEvaluationCell implements EvaluationCell {
*/
@Override
public CellType getCachedFormulaResultType() {
return _cell.getCachedFormulaResultTypeEnum();
return _cell.getCachedFormulaResultType();
}
/**
* @since POI 3.15 beta 3

View File

@ -139,11 +139,11 @@ public final class XSSFCell implements Cell {
// Copy cell value (cell type is updated implicitly)
if (policy.isCopyCellValue()) {
if (srcCell != null) {
CellType copyCellType = srcCell.getCellTypeEnum();
CellType copyCellType = srcCell.getCellType();
if (copyCellType == CellType.FORMULA && !policy.isCopyCellFormula()) {
// Copy formula result as value
// FIXME: Cached value may be stale
copyCellType = srcCell.getCachedFormulaResultTypeEnum();
copyCellType = srcCell.getCachedFormulaResultType();
}
switch (copyCellType) {
case NUMERIC:
@ -172,7 +172,7 @@ public final class XSSFCell implements Cell {
break;
default:
throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellTypeEnum());
throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellType());
}
} else { //srcCell is null
setBlank();
@ -238,12 +238,12 @@ public final class XSSFCell implements Cell {
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
* </p>
* @return the value of the cell as a boolean
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()}
* @throws IllegalStateException if the cell type returned by {@link #getCellType()}
* is not {@link CellType#BOOLEAN}, {@link CellType#BLANK} or {@link CellType#FORMULA}
*/
@Override
public boolean getBooleanCellValue() {
CellType cellType = getCellTypeEnum();
CellType cellType = getCellType();
switch(cellType) {
case BLANK:
return false;
@ -277,13 +277,13 @@ public final class XSSFCell implements Cell {
* For formulas or error cells we return the precalculated value;
* </p>
* @return the value of the cell as a number
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
*/
@Override
public double getNumericCellValue() {
CellType cellType = getCellTypeEnum();
CellType cellType = getCellType();
switch(cellType) {
case BLANK:
return 0.0;
@ -357,7 +357,7 @@ public final class XSSFCell implements Cell {
*/
@Override
public XSSFRichTextString getRichStringCellValue() {
CellType cellType = getCellTypeEnum();
CellType cellType = getCellType();
XSSFRichTextString rt;
switch (cellType) {
case BLANK:
@ -436,7 +436,7 @@ public final class XSSFCell implements Cell {
throw new IllegalArgumentException("The maximum length of cell contents (text) is 32,767 characters");
}
CellType cellType = getCellTypeEnum();
CellType cellType = getCellType();
switch (cellType){
case FORMULA:
_cell.setV(str.getString());
@ -461,7 +461,7 @@ public final class XSSFCell implements Cell {
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
*
* @return a formula for the cell
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
*/
@Override
public String getCellFormula() {
@ -474,10 +474,10 @@ public final class XSSFCell implements Cell {
*
* @param fpb evaluation workbook for reuse, if available, or null to create a new one as needed
* @return a formula for the cell
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA}
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA}
*/
protected String getCellFormula(XSSFEvaluationWorkbook fpb) {
CellType cellType = getCellTypeEnum();
CellType cellType = getCellType();
if(cellType != CellType.FORMULA) {
throw typeMismatch(CellType.FORMULA, cellType, false);
}
@ -676,19 +676,22 @@ public final class XSSFCell implements Cell {
}
/**
* Return the cell type.
*
* Will return {@link CellType} in a future version of POI.
* For forwards compatibility, do not hard-code cell type literals in your code.
* Return the cell type. Tables in an array formula return
* {@link CellType#FORMULA} for all cells, even though the formula is only defined
* in the OOXML file for the top left cell of the array.
* <p>
* NOTE: POI does not support data table formulas.
* Cells in a data table appear to POI as plain cells typed from their cached value.
*
* @return the cell type
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Deprecated
@Override
@Removal(version="3.17")
public int getCellType() {
return getCellTypeEnum().getCode();
public CellType getCellType() {
if (isFormulaCell()) {
return CellType.FORMULA;
}
return getBaseCellType(true);
}
/**
@ -701,15 +704,13 @@ public final class XSSFCell implements Cell {
*
* @return the cell type
* @since POI 3.15 beta 3
* Will be deleted when we make the CellType enum transition. See bug 59791.
* @deprecated use <code>getCellType</code> instead
*/
@Deprecated
@Removal(version = "4.2")
@Override
public CellType getCellTypeEnum() {
if (isFormulaCell()) {
return CellType.FORMULA;
}
return getBaseCellType(true);
return getCellType();
}
/**
@ -777,13 +778,13 @@ public final class XSSFCell implements Cell {
* For strings we throw an exception. For blank cells we return a null.
* </p>
* @return the value of the cell as a date
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING}
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING}
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
* @see DataFormatter for formatting this date into a string similar to how excel does.
*/
@Override
public Date getDateCellValue() {
if (getCellTypeEnum() == CellType.BLANK) {
if (getCellType() == CellType.BLANK) {
return null;
}
@ -842,7 +843,7 @@ public final class XSSFCell implements Cell {
* Returns the error message, such as #VALUE!
*
* @return the error message such as #VALUE!
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR}
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR}
* @see FormulaError
*/
public String getErrorCellString() throws IllegalStateException {
@ -861,7 +862,7 @@ public final class XSSFCell implements Cell {
* </p>
*
* @return the value of the cell as an error code
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType #ERROR}
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType #ERROR}
* @see FormulaError
*/
@Override
@ -938,24 +939,6 @@ public final class XSSFCell implements Cell {
_cell.setR(ref);
}
/**
* Set the cells type (numeric, formula or string)
*
* @throws IllegalArgumentException if the specified cell type is invalid
* @see CellType#NUMERIC
* @see CellType#STRING
* @see CellType#FORMULA
* @see CellType#BLANK
* @see CellType#BOOLEAN
* @see CellType#ERROR
* @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead.
*/
@Deprecated
@Override
@Removal(version="3.17")
public void setCellType(int cellType) {
setCellType(CellType.forInt(cellType));
}
/**
* Set the cells type (numeric, formula or string)
*
@ -963,7 +946,7 @@ public final class XSSFCell implements Cell {
*/
@Override
public void setCellType(CellType cellType) {
CellType prevType = getCellTypeEnum();
CellType prevType = getCellType();
if(isPartOfArrayFormulaGroup()){
notifyArrayFormulaChanging();
@ -1028,7 +1011,7 @@ public final class XSSFCell implements Cell {
*/
@Override
public String toString() {
switch (getCellTypeEnum()) {
switch (getCellType()) {
case NUMERIC:
if (DateUtil.isCellDateFormatted(this)) {
DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale());
@ -1047,7 +1030,7 @@ public final class XSSFCell implements Cell {
case ERROR:
return ErrorEval.getText(getErrorCellValue());
default:
return "Unknown Cell Type: " + getCellTypeEnum();
return "Unknown Cell Type: " + getCellType();
}
}
@ -1196,10 +1179,10 @@ public final class XSSFCell implements Cell {
* Usually the caller is calling setCellType() with the intention of calling
* setCellValue(boolean) straight afterwards. This method only exists to give
* the cell a somewhat reasonable value until the setCellValue() call (if at all).
* TODO - perhaps a method like setCellTypeAndValue(int, Object) should be introduced to avoid this
* TODO - perhaps a method like setCellTypeAndValue(CellType, Object) should be introduced to avoid this
*/
private boolean convertCellValueToBoolean() {
CellType cellType = getCellTypeEnum();
CellType cellType = getCellType();
if (cellType == CellType.FORMULA) {
cellType = getBaseCellType(false);
@ -1227,7 +1210,7 @@ public final class XSSFCell implements Cell {
}
private String convertCellValueToString() {
CellType cellType = getCellTypeEnum();
CellType cellType = getCellType();
switch (cellType) {
case BLANK:
@ -1312,7 +1295,7 @@ public final class XSSFCell implements Cell {
* The purpose of this method is to validate the cell state prior to modification.
* </p>
*
* @see #setCellType(int)
* @see #setCellType(CellType)
* @see #setCellFormula(String)
* @see XSSFRow#removeCell(org.apache.poi.ss.usermodel.Cell)
* @see org.apache.poi.xssf.usermodel.XSSFSheet#removeRow(org.apache.poi.ss.usermodel.Row)

View File

@ -56,24 +56,21 @@ final class XSSFEvaluationCell implements EvaluationCell {
return _cell.getBooleanCellValue();
}
/**
* 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
* @deprecated 3.15. Will return a {@link CellType} enum in the future.
*/
@Override
public int getCellType() {
public CellType getCellType() {
return _cell.getCellType();
}
/**
* @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 use <code>getCellType</code> instead
*/
@Deprecated
@Removal(version = "4.2")
@Override
public CellType getCellTypeEnum() {
return _cell.getCellTypeEnum();
return getCellType();
}
@Override
public int getColumnIndex() {
@ -115,11 +112,11 @@ final class XSSFEvaluationCell implements EvaluationCell {
*/
@Override
public CellType getCachedFormulaResultType() {
return _cell.getCachedFormulaResultTypeEnum();
return _cell.getCachedFormulaResultType();
}
/**
* @since POI 3.15 beta 3
* @deprecated 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

View File

@ -121,14 +121,14 @@ public abstract class AbstractExcelConverter
protected boolean isTextEmpty( HSSFCell cell )
{
final String value;
switch ( cell.getCellTypeEnum() )
switch ( cell.getCellType() )
{
case STRING:
// XXX: enrich
value = cell.getRichStringCellValue().getString();
break;
case FORMULA:
switch ( cell.getCachedFormulaResultTypeEnum() )
switch ( cell.getCachedFormulaResultType() )
{
case STRING:
HSSFRichTextString str = cell.getRichStringCellValue();

View File

@ -209,14 +209,14 @@ public class ExcelToFoConverter extends AbstractExcelConverter
final HSSFCellStyle cellStyle = cell.getCellStyle();
String value;
switch ( cell.getCellTypeEnum() )
switch ( cell.getCellType() )
{
case STRING:
// XXX: enrich
value = cell.getRichStringCellValue().getString();
break;
case FORMULA:
switch ( cell.getCachedFormulaResultTypeEnum() )
switch ( cell.getCachedFormulaResultType() )
{
case STRING:
HSSFRichTextString str = cell.getRichStringCellValue();
@ -245,7 +245,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
logger.log(
POILogger.WARN,
"Unexpected cell cachedFormulaResultType ("
+ cell.getCachedFormulaResultTypeEnum() + ")" );
+ cell.getCachedFormulaResultType() + ")" );
value = ExcelToHtmlUtils.EMPTY;
break;
}
@ -264,7 +264,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter
break;
default:
logger.log( POILogger.WARN,
"Unexpected cell type (" + cell.getCellTypeEnum() + ")" );
"Unexpected cell type (" + cell.getCellType() + ")" );
return true;
}

View File

@ -322,14 +322,14 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
final HSSFCellStyle cellStyle = cell.getCellStyle();
String value;
switch ( cell.getCellTypeEnum() )
switch ( cell.getCellType() )
{
case STRING:
// XXX: enrich
value = cell.getRichStringCellValue().getString();
break;
case FORMULA:
switch ( cell.getCachedFormulaResultTypeEnum() )
switch ( cell.getCachedFormulaResultType() )
{
case STRING:
HSSFRichTextString str = cell.getRichStringCellValue();
@ -358,7 +358,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
logger.log(
POILogger.WARN,
"Unexpected cell cachedFormulaResultType ("
+ cell.getCachedFormulaResultTypeEnum() + ")" );
+ cell.getCachedFormulaResultType() + ")" );
value = ExcelToHtmlUtils.EMPTY;
break;
}
@ -377,7 +377,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter
break;
default:
logger.log( POILogger.WARN,
"Unexpected cell type (" + cell.getCellTypeEnum() + ")" );
"Unexpected cell type (" + cell.getCellType() + ")" );
return true;
}

View File

@ -507,7 +507,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
HSSFRow row = sheet.getRow(i);
if (row != null) {
HSSFCell cell = row.getCell(0);
assertEquals(CellType.STRING, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCellType());
count++;
}
}
@ -1143,9 +1143,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
// Now evaluate, they should all be changed
HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb1);
eval.evaluateFormulaCellEnum(c1);
eval.evaluateFormulaCellEnum(c2);
eval.evaluateFormulaCellEnum(c3);
eval.evaluateFormulaCell(c1);
eval.evaluateFormulaCell(c2);
eval.evaluateFormulaCell(c3);
// Check that the cells now contain
// the correct values
@ -1192,14 +1192,14 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
private static void confirmCachedValue(double expectedValue, HSSFCell cell) {
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
assertEquals(expectedValue, cell.getNumericCellValue(), 0.0);
}
private static void confirmCachedValue(String expectedValue, HSSFCell cell) {
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals(CellType.STRING, cell.getCachedFormulaResultType());
assertEquals(expectedValue, cell.getRichStringCellValue().getString());
}
@ -1313,7 +1313,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
s = wb.getSheet("OneVariable Table Completed");
r = s.getRow(3);
c = r.getCell(4);
assertEquals(CellType.FORMULA, c.getCellTypeEnum());
assertEquals(CellType.FORMULA, c.getCellType());
// TODO - check the formula once tables and
// arrays are properly supported
@ -1323,7 +1323,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
s = wb.getSheet("TwoVariable Table Example");
r = s.getRow(3);
c = r.getCell(4);
assertEquals(CellType.FORMULA, c.getCellTypeEnum());
assertEquals(CellType.FORMULA, c.getCellType());
// TODO - check the formula once tables and
// arrays are properly supported
@ -1850,26 +1850,26 @@ public final class TestBugs extends BaseTestBugzillaIssues {
HSSFRow row;
row = s.getRow(0);
assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(1);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("B1", row.getCell(1).getCellFormula());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(2);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(3);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(4);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
@ -1899,31 +1899,31 @@ public final class TestBugs extends BaseTestBugzillaIssues {
s = wb2.getSheetAt(0);
row = s.getRow(0);
assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(1);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("B1", row.getCell(1).getCellFormula());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(2);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(3);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(4);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula());
assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0);
row = s.getRow(5);
assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum());
assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0);
@ -2795,12 +2795,12 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) {
assertEquals(CellType.FORMULA, intF.getCellTypeEnum());
assertEquals(CellType.FORMULA, intF.getCellType());
if (null == expectedResultOrNull) {
assertEquals(CellType.ERROR, intF.getCachedFormulaResultTypeEnum());
assertEquals(CellType.ERROR, intF.getCachedFormulaResultType());
expectedResultOrNull = "#VALUE!";
} else {
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultType());
}
assertEquals(expectedFormula, intF.getCellFormula());
@ -3026,12 +3026,12 @@ public final class TestBugs extends BaseTestBugzillaIssues {
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("IF(TRUE,\"\",\"\")", cell.getCellFormula());
assertEquals("", cell.getStringCellValue());
cell.setCellType(CellType.STRING);
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
assertEquals(CellType.BLANK, cell.getCellType());
try {
assertNull(cell.getCellFormula());
fail("Should throw an exception here");

View File

@ -55,7 +55,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
HSSFCell cell = sheet.getRow(8).getCell(0);
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
CellValue cv = fe.evaluate(cell);
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(3.72, cv.getNumberValue(), 0.0);
wb.close();
}
@ -127,7 +127,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
try {
value = hsf.evaluate(cellA1);
assertEquals(CellType.NUMERIC, value.getCellTypeEnum());
assertEquals(CellType.NUMERIC, value.getCellType());
assertEquals(5.33, value.getNumberValue(), 0.0);
} catch (RuntimeException e) {
@ -199,8 +199,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
// VLookup on a name in another file
cell = wb1.getSheetAt(0).getRow(1).getCell(2);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
// WARNING - this is wrong!
// The file name should be showing, but bug #45970 is fixed
@ -210,8 +210,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
// Simple reference to a name in another file
cell = wb1.getSheetAt(0).getRow(1).getCell(4);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
assertEquals(36.90, cell.getNumericCellValue(), 0.0001);
// TODO Correct this!
// The file name should be shown too, see bug #56742
@ -237,14 +237,14 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
// Re-check VLOOKUP one
cell = wb1.getSheetAt(0).getRow(1).getCell(2);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
assertEquals(12.30, cell.getNumericCellValue(), 0.0001);
// Re-check ref one
cell = wb1.getSheetAt(0).getRow(1).getCell(4);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
assertEquals(36.90, cell.getNumericCellValue(), 0.0001);

View File

@ -199,7 +199,7 @@ public class TestWorkbookEvaluator {
} catch (RuntimeException e) {
fail("Missing arg result not being handled correctly.");
}
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cv.getCellType());
// adding blank to 1.0 gives 1.0
assertEquals(1.0, cv.getNumberValue(), 0.0);
@ -207,7 +207,7 @@ public class TestWorkbookEvaluator {
cell.setCellFormula("\"abc\"&IF(1,,)");
fe.notifySetFormula(cell);
cv = fe.evaluate(cell);
assertEquals(CellType.STRING, cv.getCellTypeEnum());
assertEquals(CellType.STRING, cv.getCellType());
// adding blank to "abc" gives "abc"
assertEquals("abc", cv.getStringValue());
@ -215,7 +215,7 @@ public class TestWorkbookEvaluator {
cell.setCellFormula("\"abc\"&CHOOSE(2,5,,9)");
fe.notifySetFormula(cell);
cv = fe.evaluate(cell);
assertEquals(CellType.STRING, cv.getCellTypeEnum());
assertEquals(CellType.STRING, cv.getCellType());
// adding blank to "abc" gives "abc"
assertEquals("abc", cv.getStringValue());
}
@ -240,14 +240,14 @@ public class TestWorkbookEvaluator {
}
throw new RuntimeException(e);
}
assertEquals(CellType.ERROR, cv.getCellTypeEnum());
assertEquals(CellType.ERROR, cv.getCellType());
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), cv.getErrorValue());
// verify circular refs are still detected properly
fe.clearAllCachedResultValues();
cell.setCellFormula("OFFSET(A1,0,0)");
cv = fe.evaluate(cell);
assertEquals(CellType.ERROR, cv.getCellTypeEnum());
assertEquals(CellType.ERROR, cv.getCellType());
assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cv.getErrorValue());
} finally {
wb.close();
@ -387,10 +387,10 @@ public class TestWorkbookEvaluator {
CellValue result = eval.evaluate(D1);
// Call should not modify the contents
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
assertEquals(CellType.FORMULA, D1.getCellType());
assertEquals(expectedFormula, D1.getCellFormula());
assertEquals(CellType.NUMERIC, result.getCellTypeEnum());
assertEquals(CellType.NUMERIC, result.getCellType());
assertEquals(expectedResult, result.getNumberValue(), EPSILON);
testIFEqualsFormulaEvaluation_teardown(wb);
@ -536,10 +536,10 @@ public class TestWorkbookEvaluator {
CellType resultCellType = eval.evaluateFormulaCellEnum(D1);
// Call should modify the contents, but leave the formula intact
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
assertEquals(CellType.FORMULA, D1.getCellType());
assertEquals(expectedFormula, D1.getCellFormula());
assertEquals(CellType.NUMERIC, resultCellType);
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
testIFEqualsFormulaEvaluation_teardown(wb);
@ -561,7 +561,7 @@ public class TestWorkbookEvaluator {
} catch (final IllegalStateException expected) {
// expected here
}
assertEquals(CellType.NUMERIC, D1.getCellTypeEnum());
assertEquals(CellType.NUMERIC, D1.getCellType());
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
testIFEqualsFormulaEvaluation_teardown(wb);
@ -576,10 +576,10 @@ public class TestWorkbookEvaluator {
eval.evaluateAll();
// Call should modify the contents
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
assertEquals(CellType.FORMULA, D1.getCellType());
assertEquals(expectedFormula, D1.getCellFormula());
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
testIFEqualsFormulaEvaluation_teardown(wb);
@ -593,11 +593,11 @@ public class TestWorkbookEvaluator {
HSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
// Call should modify the contents
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
assertEquals(CellType.FORMULA, D1.getCellType());
// whitespace gets deleted because formula is parsed and re-rendered
assertEquals(expectedFormula, D1.getCellFormula());
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
testIFEqualsFormulaEvaluation_teardown(wb);

View File

@ -131,7 +131,7 @@ public class TestRandBetween extends TestCase {
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
@ -141,7 +141,7 @@ public class TestRandBetween extends TestCase {
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
// Check case where both inputs are of wrong type
@ -150,7 +150,7 @@ public class TestRandBetween extends TestCase {
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
}
@ -166,14 +166,14 @@ public class TestRandBetween extends TestCase {
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
bottomValueCell.setCellValue(1);
topValueCell.setCellType(CellType.BLANK);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
}

View File

@ -505,9 +505,9 @@ public final class TestCountFuncs extends TestCase {
for (int rowIx=7; rowIx<=12; rowIx++) {
HSSFRow row = sheet1.getRow(rowIx-1);
HSSFCell cellA = row.getCell(0); // cell containing a formula with COUNTIF
assertEquals(CellType.FORMULA, cellA.getCellTypeEnum());
assertEquals(CellType.FORMULA, cellA.getCellType());
HSSFCell cellC = row.getCell(2); // cell with a reference value
assertEquals(CellType.NUMERIC, cellC.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cellC.getCellType());
CellValue cv = fe.evaluate(cellA);
double actualValue = cv.getNumberValue();
@ -523,9 +523,9 @@ public final class TestCountFuncs extends TestCase {
for (int rowIx=9; rowIx<=14; rowIx++) {
HSSFRow row = sheet2.getRow(rowIx-1);
HSSFCell cellA = row.getCell(0); // cell containing a formula with COUNTIF
assertEquals(CellType.FORMULA, cellA.getCellTypeEnum());
assertEquals(CellType.FORMULA, cellA.getCellType());
HSSFCell cellC = row.getCell(2); // cell with a reference value
assertEquals(CellType.NUMERIC, cellC.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cellC.getCellType());
CellValue cv = fe.evaluate(cellA);
double actualValue = cv.getNumberValue();

View File

@ -47,13 +47,13 @@ public final class TestIsBlank extends TestCase {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
CellValue result = fe.evaluate(cell);
assertEquals(CellType.BOOLEAN, result.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, result.getCellType());
assertEquals(true, result.getBooleanValue());
cell.setCellFormula("isblank(D7:D7)");
result = fe.evaluate(cell);
assertEquals(CellType.BOOLEAN, result.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, result.getCellType());
assertEquals(true, result.getBooleanValue());
}
}

View File

@ -58,12 +58,12 @@ public final class TestNper {
cell.setCellFormula("NPER(12,4500,100000,100000)");
cell.setCellValue(15.0);
assertEquals("NPER(12,4500,100000,100000)", cell.getCellFormula());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
assertEquals(15.0, cell.getNumericCellValue(), 0.0);
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
fe.evaluateFormulaCellEnum(cell);
assertEquals(CellType.ERROR, cell.getCachedFormulaResultTypeEnum());
fe.evaluateFormulaCell(cell);
assertEquals(CellType.ERROR, cell.getCachedFormulaResultType());
assertEquals(FormulaError.NUM.getCode(), cell.getErrorCellValue());
wb.close();
}

View File

@ -973,7 +973,7 @@ public abstract class BaseTestBugzillaIssues {
assertEquals(1, cArray.length);*/
Cell cell = row.getCell(0);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
}
{ // overwrite the row
@ -1151,18 +1151,18 @@ public abstract class BaseTestBugzillaIssues {
cfs.setCellFormula("B1");
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellTypeEnum());
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellTypeEnum());
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellType());
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellType());
fe.evaluateFormulaCellEnum(cfn);
fe.evaluateFormulaCellEnum(cfs);
// Now test
assertEquals(CellType.NUMERIC, cn.getCellTypeEnum());
assertEquals(CellType.STRING, cs.getCellTypeEnum());
assertEquals(CellType.FORMULA, cfn.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cfn.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, cfs.getCellTypeEnum());
assertEquals(CellType.STRING, cfs.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, cn.getCellType());
assertEquals(CellType.STRING, cs.getCellType());
assertEquals(CellType.FORMULA, cfn.getCellType());
assertEquals(CellType.NUMERIC, cfn.getCachedFormulaResultType());
assertEquals(CellType.FORMULA, cfs.getCellType());
assertEquals(CellType.STRING, cfs.getCachedFormulaResultType());
// Different ways of retrieving
assertEquals(1.2, cn.getNumericCellValue(), 0);
@ -1406,7 +1406,7 @@ public abstract class BaseTestBugzillaIssues {
Sheet s = wb.createSheet();
Cell cell = s.createRow(0).createCell(0);
cell.setCellValue((String)null);
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
assertEquals(CellType.BLANK, cell.getCellType());
_testDataProvider.trackAllColumnsForAutosizing(s);
@ -1577,8 +1577,8 @@ public abstract class BaseTestBugzillaIssues {
Cell cell = row.getCell(cellId);
System.out.println("Formula:" + cell.getCellFormula());
if (CellType.FORMULA == cell.getCellTypeEnum()) {
CellType formulaResultType = cell.getCachedFormulaResultTypeEnum();
if (CellType.FORMULA == cell.getCellType()) {
CellType formulaResultType = cell.getCachedFormulaResultType();
System.out.println("Formula Result Type:" + formulaResultType);
}
@ -1592,8 +1592,8 @@ public abstract class BaseTestBugzillaIssues {
cell = row.getCell(cellId);
System.out.println("Formula:" + cell.getCellFormula());
if (CellType.FORMULA == cell.getCellTypeEnum()) {
CellType formulaResultType = cell.getCachedFormulaResultTypeEnum();
if (CellType.FORMULA == cell.getCellType()) {
CellType formulaResultType = cell.getCachedFormulaResultType();
System.out.println("Formula Result Type:" + formulaResultType);
}
@ -1658,9 +1658,9 @@ public abstract class BaseTestBugzillaIssues {
cell3.setCellFormula("SUM(C1:C10)");
cell3.setCellValue(65);
assertEquals(CellType.FORMULA, cell1.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell2.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell3.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell1.getCellType());
assertEquals(CellType.FORMULA, cell2.getCellType());
assertEquals(CellType.FORMULA, cell3.getCellType());
assertEquals("SUM(A1:A10)", cell1.getCellFormula());
assertEquals("SUM(B1:B10)", cell2.getCellFormula());
@ -1690,7 +1690,7 @@ public abstract class BaseTestBugzillaIssues {
for (Cell cell : row) {
String cellValue;
switch (cell.getCellTypeEnum()) {
switch (cell.getCellType()) {
case STRING:
cellValue = cell.getRichStringCellValue().getString();
break;

View File

@ -61,13 +61,13 @@ public abstract class BaseTestCell {
cell.setCellValue(1.2);
assertEquals(1.2, cell.getNumericCellValue(), 0.0001);
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING,
CellType.FORMULA, CellType.ERROR);
cell.setCellValue(false);
assertEquals(false, cell.getBooleanCellValue());
assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, cell.getCellType());
cell.setCellValue(true);
assertEquals(true, cell.getBooleanCellValue());
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.STRING,
@ -76,14 +76,14 @@ public abstract class BaseTestCell {
cell.setCellValue(factory.createRichTextString("Foo"));
assertEquals("Foo", cell.getRichStringCellValue().getString());
assertEquals("Foo", cell.getStringCellValue());
assertEquals(CellType.STRING, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCellType());
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN,
CellType.FORMULA, CellType.ERROR);
cell.setCellValue("345");
assertEquals("345", cell.getRichStringCellValue().getString());
assertEquals("345", cell.getStringCellValue());
assertEquals(CellType.STRING, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCellType());
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN,
CellType.FORMULA, CellType.ERROR);
@ -91,19 +91,19 @@ public abstract class BaseTestCell {
c.setTimeInMillis(123456789);
cell.setCellValue(c.getTime());
assertEquals(c.getTime().getTime(), cell.getDateCellValue().getTime());
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING,
CellType.FORMULA, CellType.ERROR);
cell.setCellValue(c);
assertEquals(c.getTime().getTime(), cell.getDateCellValue().getTime());
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING,
CellType.FORMULA, CellType.ERROR);
cell.setCellErrorValue(FormulaError.NA.getCode());
assertEquals(FormulaError.NA.getCode(), cell.getErrorCellValue());
assertEquals(CellType.ERROR, cell.getCellTypeEnum());
assertEquals(CellType.ERROR, cell.getCellType());
assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN,
CellType.FORMULA, CellType.STRING);
@ -142,7 +142,6 @@ public abstract class BaseTestCell {
/**
* test that Boolean (BoolErrRecord) are supported properly.
* @see testErr
*/
@Test
public void testBool() throws IOException {
@ -177,13 +176,13 @@ public abstract class BaseTestCell {
c = r.getCell(1);
assertEquals(0, c.getRowIndex());
assertEquals(1, c.getColumnIndex());
assertEquals(CellType.BOOLEAN, c.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, c.getCellType());
assertEquals("B1 value", true, c.getBooleanCellValue());
c = r.getCell(2);
assertEquals(0, c.getRowIndex());
assertEquals(2, c.getColumnIndex());
assertEquals(CellType.BOOLEAN, c.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, c.getCellType());
assertEquals("C1 value", false, c.getBooleanCellValue());
wb2.close();
@ -191,7 +190,7 @@ public abstract class BaseTestCell {
/**
* test that Error types (BoolErrRecord) are supported properly.
* @see testBool
* @see #testBool
*/
@Test
public void testErr() throws IOException {
@ -227,13 +226,13 @@ public abstract class BaseTestCell {
c = r.getCell(1);
assertEquals(0, c.getRowIndex());
assertEquals(1, c.getColumnIndex());
assertEquals(CellType.ERROR, c.getCellTypeEnum());
assertEquals(CellType.ERROR, c.getCellType());
assertEquals("B1 value == #NULL!", FormulaError.NULL.getCode(), c.getErrorCellValue());
c = r.getCell(2);
assertEquals(0, c.getRowIndex());
assertEquals(2, c.getColumnIndex());
assertEquals(CellType.ERROR, c.getCellTypeEnum());
assertEquals(CellType.ERROR, c.getCellType());
assertEquals("C1 value == #DIV/0!", FormulaError.DIV0.getCode(), c.getErrorCellValue());
wb2.close();
@ -273,7 +272,7 @@ public abstract class BaseTestCell {
r = s.getRow(0);
c = r.getCell(0);
assertEquals("Formula Cell at 0,0", CellType.FORMULA, c.getCellTypeEnum());
assertEquals("Formula Cell at 0,0", CellType.FORMULA, c.getCellType());
cs = c.getCellStyle();
assertNotNull("Formula Cell Style", cs);
@ -351,25 +350,25 @@ public abstract class BaseTestCell {
Cell c1 = r.createCell(0);
c1.setCellFormula("NA()");
assertEquals(0.0, c1.getNumericCellValue(), 0.0);
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultType());
c1.setCellValue(10);
assertEquals(10.0, c1.getNumericCellValue(), 0.0);
assertEquals(CellType.FORMULA, c1.getCellTypeEnum());
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, c1.getCellType());
assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultType());
Cell c2 = r.createCell(1);
c2.setCellFormula("NA()");
assertEquals(0.0, c2.getNumericCellValue(), 0.0);
assertEquals(CellType.NUMERIC, c2.getCachedFormulaResultTypeEnum());
assertEquals(CellType.NUMERIC, c2.getCachedFormulaResultType());
c2.setCellValue("I changed!");
assertEquals("I changed!", c2.getStringCellValue());
assertEquals(CellType.FORMULA, c2.getCellTypeEnum());
assertEquals(CellType.STRING, c2.getCachedFormulaResultTypeEnum());
assertEquals(CellType.FORMULA, c2.getCellType());
assertEquals(CellType.STRING, c2.getCachedFormulaResultType());
//calglin Cell.setCellFormula(null) for a non-formula cell
Cell c3 = r.createCell(2);
c3.setCellFormula(null);
assertEquals(CellType.BLANK, c3.getCellTypeEnum());
assertEquals(CellType.BLANK, c3.getCellType());
wb.close();
}
@ -424,11 +423,11 @@ public abstract class BaseTestCell {
Cell cell = createACell(wb);
cell.setCellValue("TRUE");
assertEquals(CellType.STRING, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCellType());
// test conversion of cell from text to boolean
cell.setCellType(CellType.BOOLEAN);
assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, cell.getCellType());
assertEquals(true, cell.getBooleanCellValue());
cell.setCellType(CellType.STRING);
assertEquals("TRUE", cell.getRichStringCellValue().getString());
@ -436,7 +435,7 @@ public abstract class BaseTestCell {
// 'false' text to bool and back
cell.setCellValue("FALSE");
cell.setCellType(CellType.BOOLEAN);
assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, cell.getCellType());
assertEquals(false, cell.getBooleanCellValue());
cell.setCellType(CellType.STRING);
assertEquals("FALSE", cell.getRichStringCellValue().getString());
@ -593,17 +592,17 @@ public abstract class BaseTestCell {
cell = row.createCell(0, CellType.NUMERIC);
cell.setCellValue(1.0);
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertEquals(1.0, cell.getNumericCellValue(), 0.0);
cell = row.createCell(1, CellType.NUMERIC);
cell.setCellValue(2.0);
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertEquals(2.0, cell.getNumericCellValue(), 0.0);
cell = row.createCell(2, CellType.FORMULA);
cell.setCellFormula("SUM(A1:B1)");
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("SUM(A1:B1)", cell.getCellFormula());
//serialize and check again
@ -611,15 +610,15 @@ public abstract class BaseTestCell {
wb1.close();
row = wb2.getSheetAt(0).getRow(0);
cell = row.getCell(0);
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertEquals(1.0, cell.getNumericCellValue(), 0.0);
cell = row.getCell(1);
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertEquals(2.0, cell.getNumericCellValue(), 0.0);
cell = row.getCell(2);
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("SUM(A1:B1)", cell.getCellFormula());
wb2.close();
}
@ -676,17 +675,17 @@ public abstract class BaseTestCell {
Cell cell0 = row.createCell(0);
cell0.setCellValue(Double.NaN);
assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellTypeEnum());
assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellType());
assertEquals("Double.NaN should change cell value to #NUM!", FormulaError.NUM, forInt(cell0.getErrorCellValue()));
Cell cell1 = row.createCell(1);
cell1.setCellValue(Double.POSITIVE_INFINITY);
assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellTypeEnum());
assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellType());
assertEquals("Double.POSITIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell1.getErrorCellValue()));
Cell cell2 = row.createCell(2);
cell2.setCellValue(Double.NEGATIVE_INFINITY);
assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellTypeEnum());
assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellType());
assertEquals("Double.NEGATIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell2.getErrorCellValue()));
Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
@ -694,15 +693,15 @@ public abstract class BaseTestCell {
row = wb2.getSheetAt(0).getRow(0);
cell0 = row.getCell(0);
assertEquals(CellType.ERROR, cell0.getCellTypeEnum());
assertEquals(CellType.ERROR, cell0.getCellType());
assertEquals(FormulaError.NUM, forInt(cell0.getErrorCellValue()));
cell1 = row.getCell(1);
assertEquals(CellType.ERROR, cell1.getCellTypeEnum());
assertEquals(CellType.ERROR, cell1.getCellType());
assertEquals(FormulaError.DIV0, forInt(cell1.getErrorCellValue()));
cell2 = row.getCell(2);
assertEquals(CellType.ERROR, cell2.getCellTypeEnum());
assertEquals(CellType.ERROR, cell2.getCellType());
assertEquals(FormulaError.DIV0, forInt(cell2.getErrorCellValue()));
wb2.close();
}
@ -903,21 +902,21 @@ public abstract class BaseTestCell {
RichTextString nullStr = null;
cell.setCellValue(nullStr);
assertEquals("", cell.getStringCellValue());
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
assertEquals(CellType.BLANK, cell.getCellType());
cell = sheet.createRow(0).createCell(1);
cell.setCellValue(1.2d);
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
cell.setCellValue(nullStr);
assertEquals("", cell.getStringCellValue());
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
assertEquals(CellType.BLANK, cell.getCellType());
cell = sheet.createRow(0).createCell(1);
cell.setCellValue(wb.getCreationHelper().createRichTextString("Test"));
assertEquals(CellType.STRING, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCellType());
cell.setCellValue(nullStr);
assertEquals("", cell.getStringCellValue());
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
assertEquals(CellType.BLANK, cell.getCellType());
wb.close();
}
@ -1015,38 +1014,4 @@ public abstract class BaseTestCell {
wb.close();
}
@Test
public void primitiveToEnumReplacementDoesNotBreakBackwardsCompatibility() throws IOException {
// bug 59836
// until we have changes POI from working on primitives (int) to enums,
// we should make sure we minimize backwards compatibility breakages.
// This method tests the old way of working with cell types, alignment, etc.
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
// Cell.CELL_TYPE_* -> CellType.*
cell.setCellValue(5.0);
assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCellType());
assertEquals(0, cell.getCellType()); //make sure that hard-coded int literals still work, even though users should be using the named constants
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); // make sure old way and new way are compatible
// make sure switch(int|Enum) still works. Cases must be statically resolvable in Java 6 ("constant expression required")
switch(cell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
// expected
break;
case Cell.CELL_TYPE_STRING:
case Cell.CELL_TYPE_BOOLEAN:
case Cell.CELL_TYPE_ERROR:
case Cell.CELL_TYPE_FORMULA:
case Cell.CELL_TYPE_BLANK:
default:
fail("unexpected cell type: " + cell.getCellType());
}
wb.close();
}
}