change CellValue#getCellType() to return an int instead of an enum for backwards compatibility (source and binary) with POI 3.14. This reverts the behavior introduced in POI 3.15 beta 3 in r1751237.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1760607 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-09-13 23:24:56 +00:00
parent 42f735fed4
commit 5d97d4c0e2
32 changed files with 89 additions and 77 deletions

View File

@ -163,7 +163,7 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator {
CellValue cv = evaluateFormulaCellValue(cell);
// cell remains a formula cell, but the cached value is changed
setCellValue(cell, cv);
return cv.getCellType();
return cv.getCellTypeEnum();
}
/**
@ -196,7 +196,7 @@ public class HSSFFormulaEvaluator extends BaseFormulaEvaluator {
}
private static void setCellValue(Cell cell, CellValue cv) {
CellType cellType = cv.getCellType();
CellType cellType = cv.getCellTypeEnum();
switch (cellType) {
case BOOLEAN:
cell.setCellValue(cv.getBooleanValue());

View File

@ -132,7 +132,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
}
protected static void setCellType(Cell cell, CellValue cv) {
CellType cellType = cv.getCellType();
CellType cellType = cv.getCellTypeEnum();
switch (cellType) {
case BOOLEAN:
case ERROR:

View File

@ -78,10 +78,22 @@ public final class CellValue {
}
/**
* @return Returns the cellType.
* @since POI 3.15
*/
public CellType getCellType() {
public CellType getCellTypeEnum() {
return _cellType;
}
/**
* @return Returns the cellType.
* @deprecated POI 3.15. Use {@link #getCellTypeEnum()} instead.
* In the future, the signature of this method will be changed to return a
* {@link CellType}.
*/
@Deprecated
public int getCellType() {
return _cellType.getCode();
}
/**
* @return Returns the errorValue.
*/

View File

@ -42,7 +42,7 @@ public class DataSources {
return new AbstractCellRangeDataSource<Number>(sheet, cellRangeAddress) {
public Number getPointAt(int index) {
CellValue cellValue = getCellValueAt(index);
if (cellValue != null && cellValue.getCellType() == CellType.NUMERIC) {
if (cellValue != null && cellValue.getCellTypeEnum() == CellType.NUMERIC) {
return Double.valueOf(cellValue.getNumberValue());
} else {
return null;
@ -59,7 +59,7 @@ public class DataSources {
return new AbstractCellRangeDataSource<String>(sheet, cellRangeAddress) {
public String getPointAt(int index) {
CellValue cellValue = getCellValueAt(index);
if (cellValue != null && cellValue.getCellType() == CellType.STRING) {
if (cellValue != null && cellValue.getCellTypeEnum() == CellType.STRING) {
return cellValue.getStringValue();
} else {
return null;

View File

@ -77,7 +77,7 @@ public abstract class BaseXSSFFormulaEvaluator extends BaseFormulaEvaluator {
CellValue cv = evaluateFormulaCellValue(cell);
// cell remains a formula cell, but the cached value is changed
setCellValue(cell, cv);
return cv.getCellType();
return cv.getCellTypeEnum();
}
/**
@ -97,7 +97,7 @@ public abstract class BaseXSSFFormulaEvaluator extends BaseFormulaEvaluator {
}
private static void setCellValue(Cell cell, CellValue cv) {
CellType cellType = cv.getCellType();
CellType cellType = cv.getCellTypeEnum();
switch (cellType) {
case BOOLEAN:
cell.setCellValue(cv.getBooleanValue());

View File

@ -110,7 +110,7 @@ public class TestStructuredReferences {
private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) {
fe.clearAllCachedResultValues();
CellValue cv = fe.evaluate(cell);
if (cv.getCellType() != CellType.NUMERIC) {
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
fail("expected numeric cell type but got " + cv.formatAsString());
}
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
@ -119,7 +119,7 @@ public class TestStructuredReferences {
private static void confirm(FormulaEvaluator fe, Cell cell, String expectedResult) {
fe.clearAllCachedResultValues();
CellValue cv = fe.evaluate(cell);
if (cv.getCellType() != CellType.STRING) {
if (cv.getCellTypeEnum() != CellType.STRING) {
fail("expected String cell type but got " + cv.formatAsString());
}
assertEquals(expectedResult, cv.getStringValue());

View File

@ -96,7 +96,7 @@ public final class TestProper {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
if (cv.getCellType() != CellType.STRING) {
if (cv.getCellTypeEnum() != CellType.STRING) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
String actualValue = cv.getStringValue();

View File

@ -205,14 +205,14 @@ public final class TestFormulaEvaluatorOnXSSF {
final CellType expectedCellType = expValue.getCellTypeEnum();
switch (expectedCellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actValue.getCellType());
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum());
break;
case BOOLEAN:
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum());
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
break;
case ERROR:
assertEquals(msg, CellType.ERROR, actValue.getCellType());
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum());
// if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values
// assertEquals(msg, expValue.getErrorCellValue(), actValue.getErrorValue());
// }
@ -220,14 +220,14 @@ public final class TestFormulaEvaluatorOnXSSF {
case FORMULA: // will never be used, since we will call method after formula evaluation
fail("Cannot expect formula as result of formula evaluation: " + msg);
case NUMERIC:
assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum());
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
// double delta = Math.abs(expValue.getNumericCellValue()-actValue.getNumberValue());
// double pctExpValue = Math.abs(0.00001*expValue.getNumericCellValue());
// assertTrue(msg, delta <= pctExpValue);
break;
case STRING:
assertEquals(msg, CellType.STRING, actValue.getCellType());
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum());
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
break;
default:

View File

@ -188,14 +188,14 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
final CellType expectedCellType = expValue.getCellTypeEnum();
switch (expectedCellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actValue.getCellType());
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum());
break;
case BOOLEAN:
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum());
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
break;
case ERROR:
assertEquals(msg, CellType.ERROR, actValue.getCellType());
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum());
// if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values
// assertEquals(msg, expected.getErrorCellValue(), actual.getErrorValue());
// }
@ -203,14 +203,14 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF {
case FORMULA: // will never be used, since we will call method after formula evaluation
fail("Cannot expect formula as result of formula evaluation: " + msg);
case NUMERIC:
assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum());
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
// double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue());
// double pctExpected = Math.abs(0.00001*expected.getNumericCellValue());
// assertTrue(msg, delta <= pctExpected);
break;
case STRING:
assertEquals(msg, CellType.STRING, actValue.getCellType());
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum());
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
break;
default:

View File

@ -304,7 +304,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
if(c.getCellTypeEnum() == CellType.FORMULA) {
CellValue cv = eval.evaluate(c);
if(cv.getCellType() == CellType.NUMERIC) {
if(cv.getCellTypeEnum() == CellType.NUMERIC) {
// assert that the calculated value agrees with
// the cached formula result calculated by Excel
String formula = c.getCellFormula();
@ -2187,7 +2187,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals("E4+E5", cell.getCellFormula());
CellValue value = evaluator.evaluate(cell);
assertEquals(CellType.ERROR, value.getCellType());
assertEquals(CellType.ERROR, value.getCellTypeEnum());
assertEquals(-60, value.getErrorValue());
assertEquals("~CIRCULAR~REF~", FormulaError.forInt(value.getErrorValue()).getString());
assertEquals("CIRCULAR_REF", FormulaError.forInt(value.getErrorValue()).toString());

View File

@ -99,7 +99,7 @@ public final class TestFormulaParserEval extends TestCase {
}
throw e;
}
assertEquals(CellType.NUMERIC, result.getCellType());
assertEquals(CellType.NUMERIC, result.getCellTypeEnum());
assertEquals(42.0, result.getNumberValue(), 0.0);
}
}

View File

@ -228,7 +228,7 @@ public final class TestSharedFormulaRecord extends TestCase {
private static void confirmCellEvaluation(HSSFWorkbook wb, HSSFCell cell, double expectedValue) {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
CellValue cv = fe.evaluate(cell);
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(expectedValue, cv.getNumberValue(), 0.0);
}

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.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
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.getCellType());
assertEquals(CellType.NUMERIC, value.getCellTypeEnum());
assertEquals(5.33, value.getNumberValue(), 0.0);
} catch (RuntimeException e) {

View File

@ -203,7 +203,7 @@ public class TestWorkbookEvaluator {
} catch (RuntimeException e) {
fail("Missing arg result not being handled correctly.");
}
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
// adding blank to 1.0 gives 1.0
assertEquals(1.0, cv.getNumberValue(), 0.0);
@ -211,7 +211,7 @@ public class TestWorkbookEvaluator {
cell.setCellFormula("\"abc\"&IF(1,,)");
fe.notifySetFormula(cell);
cv = fe.evaluate(cell);
assertEquals(CellType.STRING, cv.getCellType());
assertEquals(CellType.STRING, cv.getCellTypeEnum());
// adding blank to "abc" gives "abc"
assertEquals("abc", cv.getStringValue());
@ -219,7 +219,7 @@ public class TestWorkbookEvaluator {
cell.setCellFormula("\"abc\"&CHOOSE(2,5,,9)");
fe.notifySetFormula(cell);
cv = fe.evaluate(cell);
assertEquals(CellType.STRING, cv.getCellType());
assertEquals(CellType.STRING, cv.getCellTypeEnum());
// adding blank to "abc" gives "abc"
assertEquals("abc", cv.getStringValue());
}
@ -245,14 +245,14 @@ public class TestWorkbookEvaluator {
}
throw new RuntimeException(e);
}
assertEquals(CellType.ERROR, cv.getCellType());
assertEquals(CellType.ERROR, cv.getCellTypeEnum());
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.getCellType());
assertEquals(CellType.ERROR, cv.getCellTypeEnum());
assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cv.getErrorValue());
} finally {
wb.close();
@ -396,7 +396,7 @@ public class TestWorkbookEvaluator {
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
assertEquals(expectedFormula, D1.getCellFormula());
assertEquals(CellType.NUMERIC, result.getCellType());
assertEquals(CellType.NUMERIC, result.getCellTypeEnum());
assertEquals(expectedResult, result.getNumberValue(), EPSILON);
testIFEqualsFormulaEvaluation_teardown(wb);

View File

@ -78,18 +78,18 @@ public class TestIfError extends TestCase {
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
assertEquals("Checks that the cell is numeric",
CellType.NUMERIC, evaluator.evaluate(cell1).getCellType());
CellType.NUMERIC, evaluator.evaluate(cell1).getCellTypeEnum());
assertEquals("Divides 210 by 35 and returns 6.0",
6.0, evaluator.evaluate(cell1).getNumberValue(), accuracy);
assertEquals("Checks that the cell is numeric",
CellType.STRING, evaluator.evaluate(cell2).getCellType());
CellType.STRING, evaluator.evaluate(cell2).getCellTypeEnum());
assertEquals("Rounds -10 to a nearest multiple of -3 (-9)",
"Error in calculation", evaluator.evaluate(cell2).getStringValue());
assertEquals("Check that C1 returns string",
CellType.STRING, evaluator.evaluate(cell3).getCellType());
CellType.STRING, evaluator.evaluate(cell3).getCellTypeEnum());
assertEquals("Check that C1 returns string \"error\"",
"error", evaluator.evaluate(cell3).getStringValue());
}

View File

@ -66,7 +66,7 @@ public abstract class BaseTestCircularReferences {
* Makes sure that the specified evaluated cell value represents a circular reference error.
*/
private static void confirmCycleErrorCode(CellValue cellValue) {
assertTrue(cellValue.getCellType() == CellType.ERROR);
assertTrue(cellValue.getCellTypeEnum() == CellType.ERROR);
assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cellValue.getErrorValue());
}
@ -96,7 +96,7 @@ public abstract class BaseTestCircularReferences {
CellValue cellValue = evaluateWithCycles(wb, testCell);
assertTrue(cellValue.getCellType() == CellType.NUMERIC);
assertTrue(cellValue.getCellTypeEnum() == CellType.NUMERIC);
assertEquals(2, cellValue.getNumberValue(), 0);
wb.close();
}
@ -166,24 +166,24 @@ public abstract class BaseTestCircularReferences {
// Happy day flow - evaluate A1 first
cv = fe.evaluate(cellA1);
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(42.0, cv.getNumberValue(), 0.0);
cv = fe.evaluate(cellB1); // no circ-ref-error because A1 result is cached
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(46.0, cv.getNumberValue(), 0.0);
// Show the bug - evaluate another cell from the loop first
fe.clearAllCachedResultValues();
cv = fe.evaluate(cellB1);
// Identified bug 46898
assertNotEquals(cv.getCellType(), ErrorEval.CIRCULAR_REF_ERROR.getErrorCode());
assertEquals(CellType.NUMERIC, cv.getCellType());
assertNotEquals(cv.getCellTypeEnum(), ErrorEval.CIRCULAR_REF_ERROR.getErrorCode());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(46.0, cv.getNumberValue(), 0.0);
// start evaluation on another cell
fe.clearAllCachedResultValues();
cv = fe.evaluate(cellE1);
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(43.0, cv.getNumberValue(), 0.0);
wb.close();

View File

@ -58,7 +58,7 @@ public final class TestFormulaBugs {
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
CellValue cv = fe.evaluate(cell);
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(3.0, cv.getNumberValue(), 0.0);
wb.close();
@ -106,11 +106,11 @@ public final class TestFormulaBugs {
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
CellValue cv;
cv = fe.evaluate(cell);
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(1.0, cv.getNumberValue(), 0.0);
cv = fe.evaluate(row.getCell(1));
assertEquals(CellType.BOOLEAN, cv.getCellType());
assertEquals(CellType.BOOLEAN, cv.getCellTypeEnum());
assertEquals(true, cv.getBooleanValue());
wb.close();
@ -161,7 +161,7 @@ public final class TestFormulaBugs {
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
CellValue cv = fe.evaluate(cell);
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
wb.close();

View File

@ -190,24 +190,24 @@ public final class TestFormulasFromSpreadsheet {
final CellType cellType = expValue.getCellTypeEnum();
switch (cellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actValue.getCellType());
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum());
break;
case BOOLEAN:
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum());
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
break;
case ERROR:
assertEquals(msg, CellType.ERROR, actValue.getCellType());
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum());
assertEquals(msg, ErrorEval.getText(expValue.getErrorCellValue()), ErrorEval.getText(actValue.getErrorValue()));
break;
case FORMULA: // will never be used, since we will call method after formula evaluation
fail("Cannot expect formula as result of formula evaluation: " + msg);
case NUMERIC:
assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum());
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
break;
case STRING:
assertEquals(msg, CellType.STRING, actValue.getCellType());
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum());
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
break;
default:

View File

@ -110,24 +110,24 @@ public final class TestMultiSheetEval extends TestCase {
switch (cellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actual.getCellType());
assertEquals(msg, CellType.BLANK, actual.getCellTypeEnum());
break;
case BOOLEAN:
assertEquals(msg, CellType.BOOLEAN, actual.getCellType());
assertEquals(msg, CellType.BOOLEAN, actual.getCellTypeEnum());
assertEquals(msg, expected.getBooleanCellValue(), actual.getBooleanValue());
break;
case ERROR:
assertEquals(msg, CellType.ERROR, actual.getCellType());
assertEquals(msg, CellType.ERROR, actual.getCellTypeEnum());
assertEquals(msg, ErrorEval.getText(expected.getErrorCellValue()), ErrorEval.getText(actual.getErrorValue()));
break;
case FORMULA: // will never be used, since we will call method after formula evaluation
throw new AssertionFailedError("Cannot expect formula as result of formula evaluation: " + msg);
case NUMERIC:
assertEquals(msg, CellType.NUMERIC, actual.getCellType());
assertEquals(msg, CellType.NUMERIC, actual.getCellTypeEnum());
TestMathX.assertEquals(msg, expected.getNumericCellValue(), actual.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
break;
case STRING:
assertEquals(msg, CellType.STRING, actual.getCellType());
assertEquals(msg, CellType.STRING, actual.getCellTypeEnum());
assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getStringValue());
break;
default:

View File

@ -78,7 +78,7 @@ public final class TestPercentEval extends TestCase {
// else some other unexpected error
throw e;
}
assertEquals(CellType.NUMERIC, cv.getCellType());
assertEquals(CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(0.5, cv.getNumberValue(), 0.0);
}
}

View File

@ -155,7 +155,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
if (expectedCell.getCellTypeEnum() == CellType.ERROR) {
int expectedErrorCode = expectedCell.getErrorCellValue();
assertEquals(msg, CellType.ERROR, actualValue.getCellType());
assertEquals(msg, CellType.ERROR, actualValue.getCellTypeEnum());
assertEquals(msg, ErrorEval.getText(expectedErrorCode), actualValue.formatAsString());
assertEquals(msg, expectedErrorCode, actualValue.getErrorValue());
assertEquals(msg, ErrorEval.getText(expectedErrorCode), ErrorEval.getText(actualValue.getErrorValue()));
@ -163,11 +163,11 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
}
// unexpected error
assertNotEquals(msg, CellType.ERROR, actualValue.getCellType());
assertNotEquals(msg, CellType.ERROR, actualValue.getCellTypeEnum());
assertNotEquals(msg, formatValue(expectedCell), ErrorEval.getText(actualValue.getErrorValue()));
// wrong type error
assertEquals(msg, expectedCell.getCellTypeEnum(), actualValue.getCellType());
assertEquals(msg, expectedCell.getCellTypeEnum(), actualValue.getCellTypeEnum());
final CellType expectedCellType = expectedCell.getCellTypeEnum();
switch (expectedCellType) {

View File

@ -73,7 +73,7 @@ public final class TestAddress extends TestCase {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);
CellValue result = fe.evaluate(cell);
assertEquals(result.getCellType(), CellType.STRING);
assertEquals(result.getCellTypeEnum(), CellType.STRING);
assertEquals(expectedResult, result.getStringValue());
}
}

View File

@ -103,7 +103,7 @@ public final class TestCalendarFieldFunction extends TestCase {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
if (cv.getCellType() != CellType.NUMERIC) {
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
double actualValue = cv.getNumberValue();

View File

@ -60,7 +60,7 @@ public final class TestClean extends TestCase {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);
CellValue result = fe.evaluate(cell);
assertEquals(result.getCellType(), CellType.STRING);
assertEquals(result.getCellTypeEnum(), CellType.STRING);
assertEquals(expectedResult, result.getStringValue());
}
}

View File

@ -81,7 +81,7 @@ public final class TestDate extends TestCase {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
if (cv.getCellType() != CellType.NUMERIC) {
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
double actualValue = cv.getNumberValue();

View File

@ -66,7 +66,7 @@ public final class TestFind {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);
CellValue result = fe.evaluate(cell);
assertEquals(result.getCellType(), CellType.NUMERIC);
assertEquals(result.getCellTypeEnum(), CellType.NUMERIC);
assertEquals(expectedResult, result.getNumberValue(), 0.0);
}
@ -75,7 +75,7 @@ public final class TestFind {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);
CellValue result = fe.evaluate(cell);
assertEquals(result.getCellType(), CellType.ERROR);
assertEquals(result.getCellTypeEnum(), CellType.ERROR);
assertEquals(expectedErrorCode.getCode(), result.getErrorValue());
}
}

View File

@ -117,7 +117,7 @@ public final class TestFixed {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
assertEquals("Wrong result type: " + cv.formatAsString(), CellType.STRING, cv.getCellType());
assertEquals("Wrong result type: " + cv.formatAsString(), CellType.STRING, cv.getCellTypeEnum());
String actualValue = cv.getStringValue();
assertEquals(expectedResult, actualValue);
}
@ -127,7 +127,7 @@ public final class TestFixed {
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
assertTrue("Wrong result type: " + cv.formatAsString(),
cv.getCellType() == CellType.ERROR
cv.getCellTypeEnum() == CellType.ERROR
&& cv.getErrorValue() == FormulaError.VALUE.getCode());
}
}

View File

@ -185,7 +185,7 @@ public final class TestIndirect {
fe.clearAllCachedResultValues();
cell.setCellFormula(formula);
CellValue cv = fe.evaluate(cell);
if (cv.getCellType() != CellType.NUMERIC) {
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
fail("expected numeric cell type but got " + cv.formatAsString());
}
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
@ -196,7 +196,7 @@ public final class TestIndirect {
fe.clearAllCachedResultValues();
cell.setCellFormula(formula);
CellValue cv = fe.evaluate(cell);
if (cv.getCellType() != CellType.ERROR) {
if (cv.getCellTypeEnum() != CellType.ERROR) {
fail("expected error cell type but got " + cv.formatAsString());
}
int expCode = expectedResult.getErrorCode();

View File

@ -128,7 +128,7 @@ public final class TestIrr extends TestCase {
private static void assertFormulaResult(CellValue cv, HSSFCell cell){
double actualValue = cv.getNumberValue();
double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
assertEquals("Invalid formula result: " + cv.toString(), CellType.NUMERIC, cv.getCellType());
assertEquals("Invalid formula result: " + cv.toString(), CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(expectedValue, actualValue, 1E-4); // should agree within 0.01%
}
}

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.getCellType());
assertEquals(CellType.BOOLEAN, result.getCellTypeEnum());
assertEquals(true, result.getBooleanValue());
cell.setCellFormula("isblank(D7:D7)");
result = fe.evaluate(cell);
assertEquals(CellType.BOOLEAN, result.getCellType());
assertEquals(CellType.BOOLEAN, result.getCellTypeEnum());
assertEquals(true, result.getBooleanValue());
}
}

View File

@ -162,7 +162,7 @@ public final class TestMirr extends TestCase {
private static void assertFormulaResult(CellValue cv, HSSFCell cell) {
double actualValue = cv.getNumberValue();
double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
assertEquals("Invalid formula result: " + cv.toString(), CellType.NUMERIC, cv.getCellType());
assertEquals("Invalid formula result: " + cv.toString(), CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals(expectedValue, actualValue, 1E-8);
}
}

View File

@ -1133,8 +1133,8 @@ public abstract class BaseTestBugzillaIssues {
cfs.setCellFormula("B1");
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellType());
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellType());
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellTypeEnum());
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellTypeEnum());
fe.evaluateFormulaCellEnum(cfn);
fe.evaluateFormulaCellEnum(cfs);