update getCellType to return CellType enum instead of int
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808718 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4a4c428b6b
commit
7dad60e9d4
@ -188,7 +188,7 @@ public final class HSSFReadWrite {
|
|||||||
String value;
|
String value;
|
||||||
|
|
||||||
if(cell != null) {
|
if(cell != null) {
|
||||||
switch (cell.getCellTypeEnum()) {
|
switch (cell.getCellType()) {
|
||||||
|
|
||||||
case FORMULA:
|
case FORMULA:
|
||||||
value = "FORMULA value=" + cell.getCellFormula();
|
value = "FORMULA value=" + cell.getCellFormula();
|
||||||
@ -215,7 +215,7 @@ public final class HSSFReadWrite {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
value = "UNKNOWN value of type " + cell.getCellTypeEnum();
|
value = "UNKNOWN value of type " + cell.getCellType();
|
||||||
}
|
}
|
||||||
System.out.println("CELL col=" + cell.getColumnIndex() + " VALUE="
|
System.out.println("CELL col=" + cell.getColumnIndex() + " VALUE="
|
||||||
+ value);
|
+ value);
|
||||||
|
@ -1012,7 +1012,7 @@ public class HSSFCell implements Cell {
|
|||||||
case STRING:
|
case STRING:
|
||||||
return getStringCellValue();
|
return getStringCellValue();
|
||||||
default:
|
default:
|
||||||
return "Unknown Cell Type: " + getCellTypeEnum();
|
return "Unknown Cell Type: " + getCellType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
|
|||||||
case RETURN_NULL_AND_BLANK:
|
case RETURN_NULL_AND_BLANK:
|
||||||
return cell;
|
return cell;
|
||||||
case RETURN_BLANK_AS_NULL:
|
case RETURN_BLANK_AS_NULL:
|
||||||
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
|
boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
|
||||||
return (isBlank) ? null : cell;
|
return (isBlank) ? null : cell;
|
||||||
case CREATE_NULL_AS_BLANK:
|
case CREATE_NULL_AS_BLANK:
|
||||||
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
||||||
|
@ -93,7 +93,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cell.getCellTypeEnum()) {
|
switch (cell.getCellType()) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return CellValue.valueOf(cell.getBooleanCellValue());
|
return CellValue.valueOf(cell.getBooleanCellValue());
|
||||||
case ERROR:
|
case ERROR:
|
||||||
@ -107,7 +107,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
case BLANK:
|
case BLANK:
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
|
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
* </pre>
|
* </pre>
|
||||||
* Be aware that your cell value will be changed to hold the
|
* Be aware that your cell value will be changed to hold the
|
||||||
* result of the formula. If you simply want the formula
|
* result of the formula. If you simply want the formula
|
||||||
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}}
|
* value computed for you, use {@link #evaluateFormulaCell(Cell)}}
|
||||||
* @param cell
|
* @param cell
|
||||||
* @return the {@code cell} that was passed in, allowing for chained calls
|
* @return the {@code cell} that was passed in, allowing for chained calls
|
||||||
*/
|
*/
|
||||||
@ -133,7 +133,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
if (cell == null) {
|
if (cell == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
if (cell.getCellType() == CellType.FORMULA) {
|
||||||
CellValue cv = evaluateFormulaCellValue(cell);
|
CellValue cv = evaluateFormulaCellValue(cell);
|
||||||
setCellValue(cell, cv);
|
setCellValue(cell, cv);
|
||||||
setCellType(cell, cv); // cell will no longer be a formula cell
|
setCellType(cell, cv); // cell will no longer be a formula cell
|
||||||
@ -153,7 +153,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
* so you know what kind of value is also stored with
|
* so you know what kind of value is also stored with
|
||||||
* the formula.
|
* the formula.
|
||||||
* <pre>
|
* <pre>
|
||||||
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
|
* CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell);
|
||||||
* </pre>
|
* </pre>
|
||||||
* Be aware that your cell will hold both the formula,
|
* Be aware that your cell will hold both the formula,
|
||||||
* and the result. If you want the cell replaced with
|
* and the result. If you want the cell replaced with
|
||||||
@ -164,13 +164,13 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CellType evaluateFormulaCell(Cell cell) {
|
public CellType evaluateFormulaCell(Cell cell) {
|
||||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
if (cell == null || cell.getCellType() != CellType.FORMULA) {
|
||||||
return CellType._NONE;
|
return CellType._NONE;
|
||||||
}
|
}
|
||||||
CellValue cv = evaluateFormulaCellValue(cell);
|
CellValue cv = evaluateFormulaCellValue(cell);
|
||||||
// cell remains a formula cell, but the cached value is changed
|
// cell remains a formula cell, but the cached value is changed
|
||||||
setCellValue(cell, cv);
|
setCellValue(cell, cv);
|
||||||
return cv.getCellTypeEnum();
|
return cv.getCellType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,7 +183,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
* so you know what kind of value is also stored with
|
* so you know what kind of value is also stored with
|
||||||
* the formula.
|
* the formula.
|
||||||
* <pre>
|
* <pre>
|
||||||
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
|
* CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell);
|
||||||
* </pre>
|
* </pre>
|
||||||
* Be aware that your cell will hold both the formula,
|
* Be aware that your cell will hold both the formula,
|
||||||
* and the result. If you want the cell replaced with
|
* and the result. If you want the cell replaced with
|
||||||
@ -202,7 +202,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void setCellType(Cell cell, CellValue cv) {
|
protected static void setCellType(Cell cell, CellValue cv) {
|
||||||
CellType cellType = cv.getCellTypeEnum();
|
CellType cellType = cv.getCellType();
|
||||||
switch (cellType) {
|
switch (cellType) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
case ERROR:
|
case ERROR:
|
||||||
@ -224,7 +224,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
protected abstract RichTextString createRichTextString(String str);
|
protected abstract RichTextString createRichTextString(String str);
|
||||||
|
|
||||||
protected void setCellValue(Cell cell, CellValue cv) {
|
protected void setCellValue(Cell cell, CellValue cv) {
|
||||||
CellType cellType = cv.getCellTypeEnum();
|
CellType cellType = cv.getCellType();
|
||||||
switch (cellType) {
|
switch (cellType) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
cell.setCellValue(cv.getBooleanValue());
|
cell.setCellValue(cv.getBooleanValue());
|
||||||
@ -269,8 +269,8 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
|
|||||||
|
|
||||||
for(Row r : sheet) {
|
for(Row r : sheet) {
|
||||||
for (Cell c : r) {
|
for (Cell c : r) {
|
||||||
if (c.getCellTypeEnum() == CellType.FORMULA) {
|
if (c.getCellType() == CellType.FORMULA) {
|
||||||
evaluator.evaluateFormulaCellEnum(c);
|
evaluator.evaluateFormulaCell(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ final class EvaluationCache {
|
|||||||
Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
|
Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
|
||||||
PlainValueCellCacheEntry pcce = _plainCellCache.get(loc);
|
PlainValueCellCacheEntry pcce = _plainCellCache.get(loc);
|
||||||
|
|
||||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
if (cell.getCellType() == CellType.FORMULA) {
|
||||||
if (fcce == null) {
|
if (fcce == null) {
|
||||||
fcce = new FormulaCellCacheEntry();
|
fcce = new FormulaCellCacheEntry();
|
||||||
if (pcce == null) {
|
if (pcce == null) {
|
||||||
@ -197,7 +197,7 @@ final class EvaluationCache {
|
|||||||
}
|
}
|
||||||
public void notifyDeleteCell(int bookIndex, int sheetIndex, EvaluationCell cell) {
|
public void notifyDeleteCell(int bookIndex, int sheetIndex, EvaluationCell cell) {
|
||||||
|
|
||||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
if (cell.getCellType() == CellType.FORMULA) {
|
||||||
FormulaCellCacheEntry fcce = _formulaCellCache.remove(cell);
|
FormulaCellCacheEntry fcce = _formulaCellCache.remove(cell);
|
||||||
if (fcce == null) {
|
if (fcce == null) {
|
||||||
// formula cell has not been evaluated yet
|
// formula cell has not been evaluated yet
|
||||||
|
@ -47,7 +47,7 @@ package org.apache.poi.ss.formula;
|
|||||||
* <li>To retain freedom to change any cell definition at any time, an application may classify all
|
* <li>To retain freedom to change any cell definition at any time, an application may classify all
|
||||||
* cells as 'not final'. This freedom comes at the expense of greater memory consumption.</li>
|
* cells as 'not final'. This freedom comes at the expense of greater memory consumption.</li>
|
||||||
* <li>For the purpose of these classifications, setting the cached formula result of a cell (for
|
* <li>For the purpose of these classifications, setting the cached formula result of a cell (for
|
||||||
* example in {@link org.apache.poi.ss.usermodel.FormulaEvaluator#evaluateFormulaCellEnum(org.apache.poi.ss.usermodel.Cell)})
|
* example in {@link org.apache.poi.ss.usermodel.FormulaEvaluator#evaluateFormulaCell(org.apache.poi.ss.usermodel.Cell)})
|
||||||
* does not constitute changing the definition of the cell.</li>
|
* does not constitute changing the definition of the cell.</li>
|
||||||
* <li>Updating cells which have been classified as 'final' will cause the evaluator to behave
|
* <li>Updating cells which have been classified as 'final' will cause the evaluator to behave
|
||||||
* unpredictably (typically ignoring the update).</li>
|
* unpredictably (typically ignoring the update).</li>
|
||||||
|
@ -112,7 +112,7 @@ public final class ForkedEvaluator {
|
|||||||
public ValueEval evaluate(String sheetName, int rowIndex, int columnIndex) {
|
public ValueEval evaluate(String sheetName, int rowIndex, int columnIndex) {
|
||||||
EvaluationCell cell = _sewb.getEvaluationCell(sheetName, rowIndex, columnIndex);
|
EvaluationCell cell = _sewb.getEvaluationCell(sheetName, rowIndex, columnIndex);
|
||||||
|
|
||||||
switch (cell.getCellTypeEnum()) {
|
switch (cell.getCellType()) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return BoolEval.valueOf(cell.getBooleanCellValue());
|
return BoolEval.valueOf(cell.getBooleanCellValue());
|
||||||
case ERROR:
|
case ERROR:
|
||||||
@ -126,7 +126,7 @@ public final class ForkedEvaluator {
|
|||||||
case BLANK:
|
case BLANK:
|
||||||
return null;
|
return null;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
|
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -983,7 +983,7 @@ public class DataFormatter implements Observer {
|
|||||||
if (evaluator == null) {
|
if (evaluator == null) {
|
||||||
return cell.getCellFormula();
|
return cell.getCellFormula();
|
||||||
}
|
}
|
||||||
cellType = evaluator.evaluateFormulaCellEnum(cell);
|
cellType = evaluator.evaluateFormulaCell(cell);
|
||||||
}
|
}
|
||||||
switch (cellType) {
|
switch (cellType) {
|
||||||
case NUMERIC :
|
case NUMERIC :
|
||||||
|
@ -114,7 +114,7 @@ public interface FormulaEvaluator {
|
|||||||
* so you know what kind of value is also stored with
|
* so you know what kind of value is also stored with
|
||||||
* the formula.
|
* the formula.
|
||||||
* <pre>
|
* <pre>
|
||||||
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
|
* CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell);
|
||||||
* </pre>
|
* </pre>
|
||||||
* Be aware that your cell will hold both the formula,
|
* Be aware that your cell will hold both the formula,
|
||||||
* and the result. If you want the cell replaced with
|
* and the result. If you want the cell replaced with
|
||||||
@ -143,7 +143,7 @@ public interface FormulaEvaluator {
|
|||||||
* </pre>
|
* </pre>
|
||||||
* Be aware that your cell value will be changed to hold the
|
* Be aware that your cell value will be changed to hold the
|
||||||
* result of the formula. If you simply want the formula
|
* result of the formula. If you simply want the formula
|
||||||
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}
|
* value computed for you, use {@link #evaluateFormulaCell(Cell)}
|
||||||
* @param cell
|
* @param cell
|
||||||
*/
|
*/
|
||||||
Cell evaluateInCell(Cell cell);
|
Cell evaluateInCell(Cell cell);
|
||||||
|
@ -69,7 +69,7 @@ public class SheetUtil {
|
|||||||
*
|
*
|
||||||
* See Bugzilla #50021
|
* See Bugzilla #50021
|
||||||
*/
|
*/
|
||||||
private static final FormulaEvaluator dummyEvaluator = new FormulaEvaluator(){
|
private static final FormulaEvaluator dummyEvaluator = new FormulaEvaluator() {
|
||||||
@Override
|
@Override
|
||||||
public void clearAllCachedResultValues(){}
|
public void clearAllCachedResultValues(){}
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,7 +101,7 @@ public class CellWalk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEmpty(Cell cell) {
|
private boolean isEmpty(Cell cell) {
|
||||||
return (cell.getCellTypeEnum() == CellType.BLANK);
|
return (cell.getCellType() == CellType.BLANK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,8 +106,8 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
|||||||
// Evaluate what we have
|
// Evaluate what we have
|
||||||
for (Row r : sheet) {
|
for (Row r : sheet) {
|
||||||
for (Cell c : r) {
|
for (Cell c : r) {
|
||||||
if (c.getCellTypeEnum() == CellType.FORMULA) {
|
if (c.getCellType() == CellType.FORMULA) {
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ public class SheetDataWriter implements Closeable {
|
|||||||
// APIs
|
// APIs
|
||||||
writeAttribute("s", Integer.toString(cellStyle.getIndex() & 0xffff));
|
writeAttribute("s", Integer.toString(cellStyle.getIndex() & 0xffff));
|
||||||
}
|
}
|
||||||
CellType cellType = cell.getCellTypeEnum();
|
CellType cellType = cell.getCellType();
|
||||||
switch (cellType) {
|
switch (cellType) {
|
||||||
case BLANK: {
|
case BLANK: {
|
||||||
_out.write('>');
|
_out.write('>');
|
||||||
|
@ -276,7 +276,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
|||||||
case RETURN_NULL_AND_BLANK:
|
case RETURN_NULL_AND_BLANK:
|
||||||
return cell;
|
return cell;
|
||||||
case RETURN_BLANK_AS_NULL:
|
case RETURN_BLANK_AS_NULL:
|
||||||
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
|
boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
|
||||||
return (isBlank) ? null : cell;
|
return (isBlank) ? null : cell;
|
||||||
case CREATE_NULL_AS_BLANK:
|
case CREATE_NULL_AS_BLANK:
|
||||||
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
|
||||||
@ -496,7 +496,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
|||||||
if(xcell.isPartOfArrayFormulaGroup()) {
|
if(xcell.isPartOfArrayFormulaGroup()) {
|
||||||
xcell.notifyArrayFormulaChanging();
|
xcell.notifyArrayFormulaChanging();
|
||||||
}
|
}
|
||||||
if(cell.getCellTypeEnum() == CellType.FORMULA) {
|
if(cell.getCellType() == CellType.FORMULA) {
|
||||||
_sheet.getWorkbook().onDeleteFormula(xcell);
|
_sheet.getWorkbook().onDeleteFormula(xcell);
|
||||||
}
|
}
|
||||||
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
|
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
|
||||||
@ -636,7 +636,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
|||||||
else {
|
else {
|
||||||
for (final Cell c : srcRow){
|
for (final Cell c : srcRow){
|
||||||
final XSSFCell srcCell = (XSSFCell)c;
|
final XSSFCell srcCell = (XSSFCell)c;
|
||||||
final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellTypeEnum());
|
final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellType());
|
||||||
destCell.copyCellFrom(srcCell, policy);
|
destCell.copyCellFrom(srcCell, policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class TestStructuredReferences {
|
|||||||
private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) {
|
private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) {
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
CellValue cv = fe.evaluate(cell);
|
CellValue cv = fe.evaluate(cell);
|
||||||
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
|
if (cv.getCellType() != CellType.NUMERIC) {
|
||||||
fail("expected numeric cell type but got " + cv.formatAsString());
|
fail("expected numeric cell type but got " + cv.formatAsString());
|
||||||
}
|
}
|
||||||
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
|
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
|
||||||
@ -122,7 +122,7 @@ public class TestStructuredReferences {
|
|||||||
private static void confirm(FormulaEvaluator fe, Cell cell, String expectedResult) {
|
private static void confirm(FormulaEvaluator fe, Cell cell, String expectedResult) {
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
CellValue cv = fe.evaluate(cell);
|
CellValue cv = fe.evaluate(cell);
|
||||||
if (cv.getCellTypeEnum() != CellType.STRING) {
|
if (cv.getCellType() != CellType.STRING) {
|
||||||
fail("expected String cell type but got " + cv.formatAsString());
|
fail("expected String cell type but got " + cv.formatAsString());
|
||||||
}
|
}
|
||||||
assertEquals(expectedResult, cv.getStringValue());
|
assertEquals(expectedResult, cv.getStringValue());
|
||||||
|
@ -95,7 +95,7 @@ public final class TestProper {
|
|||||||
cell11.setCellFormula(formulaText);
|
cell11.setCellFormula(formulaText);
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
CellValue cv = evaluator.evaluate(cell11);
|
CellValue cv = evaluator.evaluate(cell11);
|
||||||
if (cv.getCellTypeEnum() != CellType.STRING) {
|
if (cv.getCellType() != CellType.STRING) {
|
||||||
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
|
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
|
||||||
}
|
}
|
||||||
String actualValue = cv.getStringValue();
|
String actualValue = cv.getStringValue();
|
||||||
|
@ -106,7 +106,7 @@ public final class TestSXSSFFormulaEvaluation {
|
|||||||
|
|
||||||
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
try {
|
try {
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
fail("Evaluate shouldn't work, as reference outside the window");
|
fail("Evaluate shouldn't work, as reference outside the window");
|
||||||
} catch(SXSSFFormulaEvaluator.RowFlushedException e) {
|
} catch(SXSSFFormulaEvaluator.RowFlushedException e) {
|
||||||
// Expected
|
// Expected
|
||||||
@ -152,7 +152,7 @@ public final class TestSXSSFFormulaEvaluation {
|
|||||||
c.setCellFormula("A1*2");
|
c.setCellFormula("A1*2");
|
||||||
|
|
||||||
assertEquals(0, (int)c.getNumericCellValue());
|
assertEquals(0, (int)c.getNumericCellValue());
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
assertEquals(3, (int)c.getNumericCellValue());
|
assertEquals(3, (int)c.getNumericCellValue());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
@ -168,12 +168,12 @@ public final class TestSXSSFFormulaEvaluation {
|
|||||||
SXSSFCell c = s.createRow(0).createCell(0);
|
SXSSFCell c = s.createRow(0).createCell(0);
|
||||||
c.setCellFormula("1+2");
|
c.setCellFormula("1+2");
|
||||||
assertEquals(0, (int)c.getNumericCellValue());
|
assertEquals(0, (int)c.getNumericCellValue());
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
assertEquals(3, (int)c.getNumericCellValue());
|
assertEquals(3, (int)c.getNumericCellValue());
|
||||||
|
|
||||||
c = s.createRow(1).createCell(0);
|
c = s.createRow(1).createCell(0);
|
||||||
c.setCellFormula("CONCATENATE(\"hello\",\" \",\"world\")");
|
c.setCellFormula("CONCATENATE(\"hello\",\" \",\"world\")");
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
assertEquals("hello world", c.getStringCellValue());
|
assertEquals("hello world", c.getStringCellValue());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
|
@ -190,7 +190,7 @@ public final class TestFormulaEvaluatorOnXSSF {
|
|||||||
for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
|
for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
|
||||||
Cell c = formulasRow.getCell(colnum);
|
Cell c = formulasRow.getCell(colnum);
|
||||||
assumeNotNull(c);
|
assumeNotNull(c);
|
||||||
assumeTrue(c.getCellTypeEnum() == CellType.FORMULA);
|
assumeTrue(c.getCellType() == CellType.FORMULA);
|
||||||
ignoredFormulaTestCase(c.getCellFormula());
|
ignoredFormulaTestCase(c.getCellFormula());
|
||||||
|
|
||||||
CellValue actValue = evaluator.evaluate(c);
|
CellValue actValue = evaluator.evaluate(c);
|
||||||
@ -202,17 +202,17 @@ public final class TestFormulaEvaluatorOnXSSF {
|
|||||||
assertNotNull(msg + " - Bad setup data expected value is null", expValue);
|
assertNotNull(msg + " - Bad setup data expected value is null", expValue);
|
||||||
assertNotNull(msg + " - actual value was null", actValue);
|
assertNotNull(msg + " - actual value was null", actValue);
|
||||||
|
|
||||||
final CellType expectedCellType = expValue.getCellTypeEnum();
|
final CellType expectedCellType = expValue.getCellType();
|
||||||
switch (expectedCellType) {
|
switch (expectedCellType) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.BLANK, actValue.getCellType());
|
||||||
break;
|
break;
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
|
||||||
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
|
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.ERROR, actValue.getCellType());
|
||||||
// if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values
|
// if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values
|
||||||
// assertEquals(msg, expValue.getErrorCellValue(), actValue.getErrorValue());
|
// 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
|
case FORMULA: // will never be used, since we will call method after formula evaluation
|
||||||
fail("Cannot expect formula as result of formula evaluation: " + msg);
|
fail("Cannot expect formula as result of formula evaluation: " + msg);
|
||||||
case NUMERIC:
|
case NUMERIC:
|
||||||
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
|
||||||
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
|
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
|
||||||
// double delta = Math.abs(expValue.getNumericCellValue()-actValue.getNumberValue());
|
// double delta = Math.abs(expValue.getNumericCellValue()-actValue.getNumberValue());
|
||||||
// double pctExpValue = Math.abs(0.00001*expValue.getNumericCellValue());
|
// double pctExpValue = Math.abs(0.00001*expValue.getNumericCellValue());
|
||||||
// assertTrue(msg, delta <= pctExpValue);
|
// assertTrue(msg, delta <= pctExpValue);
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.STRING, actValue.getCellType());
|
||||||
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
|
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -264,10 +264,10 @@ public final class TestFormulaEvaluatorOnXSSF {
|
|||||||
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
if(cell.getCellType() == CellType.BLANK) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
if(cell.getCellType() == CellType.STRING) {
|
||||||
return cell.getRichStringCellValue().getString();
|
return cell.getRichStringCellValue().getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,14 +666,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
assertEquals(3.0, c.getNumericCellValue(), 0);
|
assertEquals(3.0, c.getNumericCellValue(), 0);
|
||||||
|
|
||||||
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
formulaEvaluator.evaluateFormulaCellEnum(c);
|
formulaEvaluator.evaluateFormulaCell(c);
|
||||||
|
|
||||||
assertEquals("SUM(\n1,2\n)", c.getCellFormula());
|
assertEquals("SUM(\n1,2\n)", c.getCellFormula());
|
||||||
assertEquals(3.0, c.getNumericCellValue(), 0);
|
assertEquals(3.0, c.getNumericCellValue(), 0);
|
||||||
|
|
||||||
// For 51875
|
// For 51875
|
||||||
Cell b3 = s.getRow(2).getCell(1);
|
Cell b3 = s.getRow(2).getCell(1);
|
||||||
formulaEvaluator.evaluateFormulaCellEnum(b3);
|
formulaEvaluator.evaluateFormulaCell(b3);
|
||||||
assertEquals("B1+B2", b3.getCellFormula()); // The newline is lost for shared formulas
|
assertEquals("B1+B2", b3.getCellFormula()); // The newline is lost for shared formulas
|
||||||
assertEquals(3.0, b3.getNumericCellValue(), 0);
|
assertEquals(3.0, b3.getNumericCellValue(), 0);
|
||||||
|
|
||||||
@ -1375,8 +1375,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
// Try evaluating both
|
// Try evaluating both
|
||||||
XSSFFormulaEvaluator eval = new XSSFFormulaEvaluator(wb);
|
XSSFFormulaEvaluator eval = new XSSFFormulaEvaluator(wb);
|
||||||
eval.evaluateFormulaCellEnum(c1);
|
eval.evaluateFormulaCell(c1);
|
||||||
eval.evaluateFormulaCellEnum(c2);
|
eval.evaluateFormulaCell(c2);
|
||||||
|
|
||||||
assertEquals(20.0, c1.getNumericCellValue(), 0);
|
assertEquals(20.0, c1.getNumericCellValue(), 0);
|
||||||
assertEquals(20.0, c2.getNumericCellValue(), 0);
|
assertEquals(20.0, c2.getNumericCellValue(), 0);
|
||||||
@ -2935,7 +2935,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
cell = row.getCell(1);
|
cell = row.getCell(1);
|
||||||
|
|
||||||
assertEquals(CellType.BLANK, cell.getCellType());
|
assertEquals(CellType.BLANK, cell.getCellType());
|
||||||
assertEquals(CellType._NONE, evaluator.evaluateFormulaCellEnum(cell));
|
assertEquals(CellType._NONE, evaluator.evaluateFormulaCell(cell));
|
||||||
|
|
||||||
// A3
|
// A3
|
||||||
row = worksheet.getRow(2);
|
row = worksheet.getRow(2);
|
||||||
@ -2943,7 +2943,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("IF(ISBLANK(B3),\"\",B3)", cell.getCellFormula());
|
assertEquals("IF(ISBLANK(B3),\"\",B3)", cell.getCellFormula());
|
||||||
assertEquals(CellType.STRING, evaluator.evaluateFormulaCellEnum(cell));
|
assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(cell));
|
||||||
CellValue value = evaluator.evaluate(cell);
|
CellValue value = evaluator.evaluate(cell);
|
||||||
assertEquals("", value.getStringValue());
|
assertEquals("", value.getStringValue());
|
||||||
|
|
||||||
@ -2953,7 +2953,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
assertEquals(CellType.FORMULA, cell.getCellType());
|
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("COUNTBLANK(A1:A4)", cell.getCellFormula());
|
assertEquals("COUNTBLANK(A1:A4)", cell.getCellFormula());
|
||||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(cell));
|
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(cell));
|
||||||
value = evaluator.evaluate(cell);
|
value = evaluator.evaluate(cell);
|
||||||
assertEquals(1.0, value.getNumberValue(), 0.1);
|
assertEquals(1.0, value.getNumberValue(), 0.1);
|
||||||
|
|
||||||
|
@ -135,13 +135,13 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
assertNull(str.getString());
|
assertNull(str.getString());
|
||||||
cell_0.setCellValue(str);
|
cell_0.setCellValue(str);
|
||||||
assertEquals(0, sst.getCount());
|
assertEquals(0, sst.getCount());
|
||||||
assertEquals(CellType.BLANK, cell_0.getCellTypeEnum());
|
assertEquals(CellType.BLANK, cell_0.getCellType());
|
||||||
|
|
||||||
//case 2. cell.setCellValue((String)null);
|
//case 2. cell.setCellValue((String)null);
|
||||||
Cell cell_1 = row.createCell(1);
|
Cell cell_1 = row.createCell(1);
|
||||||
cell_1.setCellValue((String)null);
|
cell_1.setCellValue((String)null);
|
||||||
assertEquals(0, sst.getCount());
|
assertEquals(0, sst.getCount());
|
||||||
assertEquals(CellType.BLANK, cell_1.getCellTypeEnum());
|
assertEquals(CellType.BLANK, cell_1.getCellType());
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml
|
CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml
|
||||||
|
|
||||||
cell.setCellFormula("A2");
|
cell.setCellFormula("A2");
|
||||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("A2", cell.getCellFormula());
|
assertEquals("A2", cell.getCellFormula());
|
||||||
//the value is not set and cell's type='N' which means blank
|
//the value is not set and cell's type='N' which means blank
|
||||||
assertEquals(STCellType.N, ctCell.getT());
|
assertEquals(STCellType.N, ctCell.getT());
|
||||||
@ -161,7 +161,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
//set cached formula value
|
//set cached formula value
|
||||||
cell.setCellValue("t='str'");
|
cell.setCellValue("t='str'");
|
||||||
//we are still of 'formula' type
|
//we are still of 'formula' type
|
||||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals("A2", cell.getCellFormula());
|
assertEquals("A2", cell.getCellFormula());
|
||||||
//cached formula value is set and cell's type='STR'
|
//cached formula value is set and cell's type='STR'
|
||||||
assertEquals(STCellType.STR, ctCell.getT());
|
assertEquals(STCellType.STR, ctCell.getT());
|
||||||
@ -169,14 +169,14 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
|
|
||||||
//now remove the formula, the cached formula result remains
|
//now remove the formula, the cached formula result remains
|
||||||
cell.setCellFormula(null);
|
cell.setCellFormula(null);
|
||||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
assertEquals(CellType.STRING, cell.getCellType());
|
||||||
assertEquals(STCellType.STR, ctCell.getT());
|
assertEquals(STCellType.STR, ctCell.getT());
|
||||||
//the line below failed prior to fix of Bug #47889
|
//the line below failed prior to fix of Bug #47889
|
||||||
assertEquals("t='str'", cell.getStringCellValue());
|
assertEquals("t='str'", cell.getStringCellValue());
|
||||||
|
|
||||||
//revert to a blank cell
|
//revert to a blank cell
|
||||||
cell.setCellValue((String)null);
|
cell.setCellValue((String)null);
|
||||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
assertEquals(CellType.BLANK, cell.getCellType());
|
||||||
assertEquals(STCellType.N, ctCell.getT());
|
assertEquals(STCellType.N, ctCell.getT());
|
||||||
assertEquals("", cell.getStringCellValue());
|
assertEquals("", cell.getStringCellValue());
|
||||||
} finally {
|
} finally {
|
||||||
@ -196,7 +196,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
|
|
||||||
//try a string cell
|
//try a string cell
|
||||||
cell = sh.getRow(0).getCell(0);
|
cell = sh.getRow(0).getCell(0);
|
||||||
assertEquals(CellType.STRING, cell.getCellTypeEnum());
|
assertEquals(CellType.STRING, cell.getCellType());
|
||||||
assertEquals("a", cell.getStringCellValue());
|
assertEquals("a", cell.getStringCellValue());
|
||||||
assertEquals("a", cell.toString());
|
assertEquals("a", cell.toString());
|
||||||
//Gnumeric produces spreadsheets without styles
|
//Gnumeric produces spreadsheets without styles
|
||||||
@ -205,7 +205,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
|
|
||||||
//try a numeric cell
|
//try a numeric cell
|
||||||
cell = sh.getRow(1).getCell(0);
|
cell = sh.getRow(1).getCell(0);
|
||||||
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, cell.getCellType());
|
||||||
assertEquals(1.0, cell.getNumericCellValue(), 0);
|
assertEquals(1.0, cell.getNumericCellValue(), 0);
|
||||||
assertEquals("1.0", cell.toString());
|
assertEquals("1.0", cell.toString());
|
||||||
//Gnumeric produces spreadsheets without styles
|
//Gnumeric produces spreadsheets without styles
|
||||||
@ -515,7 +515,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
final CellCopyPolicy policy = new CellCopyPolicy();
|
final CellCopyPolicy policy = new CellCopyPolicy();
|
||||||
destCell.copyCellFrom(srcCell, policy);
|
destCell.copyCellFrom(srcCell, policy);
|
||||||
|
|
||||||
assertEquals(CellType.FORMULA, destCell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, destCell.getCellType());
|
||||||
assertEquals("2+3", destCell.getCellFormula());
|
assertEquals("2+3", destCell.getCellFormula());
|
||||||
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
||||||
}
|
}
|
||||||
@ -527,7 +527,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
// Paste values only
|
// Paste values only
|
||||||
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build();
|
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build();
|
||||||
destCell.copyCellFrom(srcCell, policy);
|
destCell.copyCellFrom(srcCell, policy);
|
||||||
assertEquals(CellType.NUMERIC, destCell.getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, destCell.getCellType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -554,8 +554,8 @@ public final class TestXSSFCell extends BaseTestXCell {
|
|||||||
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
||||||
|
|
||||||
// Old cell value should not have been overwritten
|
// Old cell value should not have been overwritten
|
||||||
assertNotEquals(CellType.BLANK, destCell.getCellTypeEnum());
|
assertNotEquals(CellType.BLANK, destCell.getCellType());
|
||||||
assertEquals(CellType.BOOLEAN, destCell.getCellTypeEnum());
|
assertEquals(CellType.BOOLEAN, destCell.getCellType());
|
||||||
assertEquals(true, destCell.getBooleanCellValue());
|
assertEquals(true, destCell.getBooleanCellValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ public final class TestXSSFFormulaParser {
|
|||||||
for (Cell cell : row) {
|
for (Cell cell : row) {
|
||||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||||
try {
|
try {
|
||||||
evaluator.evaluateFormulaCellEnum(cell);
|
evaluator.evaluateFormulaCell(cell);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CellReference cellRef = new CellReference(cell.getRowIndex(), cell.getColumnIndex());
|
CellReference cellRef = new CellReference(cell.getRowIndex(), cell.getColumnIndex());
|
||||||
throw new RuntimeException("error at: " + cellRef, e);
|
throw new RuntimeException("error at: " + cellRef, e);
|
||||||
|
@ -183,7 +183,7 @@ public final class TestXSSFRow extends BaseTestXRow {
|
|||||||
assertSame("existing references to externObserverRow are still valid", externObserverRow, sheet2.getRow(0));
|
assertSame("existing references to externObserverRow are still valid", externObserverRow, sheet2.getRow(0));
|
||||||
|
|
||||||
// Make sure copyRowFrom actually copied row (this is tested elsewhere)
|
// Make sure copyRowFrom actually copied row (this is tested elsewhere)
|
||||||
assertEquals(CellType.STRING, destRow.getCell(0).getCellTypeEnum());
|
assertEquals(CellType.STRING, destRow.getCell(0).getCellType());
|
||||||
assertEquals("hello", destRow.getCell(0).getStringCellValue());
|
assertEquals("hello", destRow.getCell(0).getStringCellValue());
|
||||||
|
|
||||||
// We don't want #REF! errors if we copy a row that contains cells that are referred to by other cells outside of copied region
|
// We don't want #REF! errors if we copy a row that contains cells that are referred to by other cells outside of copied region
|
||||||
|
@ -2424,7 +2424,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
// Check the evaluated result
|
// Check the evaluated result
|
||||||
HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
|
HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
assertEquals(4.0, c.getNumericCellValue(), 0);
|
assertEquals(4.0, c.getNumericCellValue(), 0);
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public class TestExternalReferenceChange extends TestCase {
|
|||||||
new String[]{MAIN_WORKBOOK_FILENAME, SOURCE_WORKBOOK_FILENAME},
|
new String[]{MAIN_WORKBOOK_FILENAME, SOURCE_WORKBOOK_FILENAME},
|
||||||
new HSSFFormulaEvaluator[] {lMainWorkbookEvaluator, lSourceEvaluator});
|
new HSSFFormulaEvaluator[] {lMainWorkbookEvaluator, lSourceEvaluator});
|
||||||
|
|
||||||
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lA1Cell));
|
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
|
||||||
|
|
||||||
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ public final class TestFormulaEvaluatorBugs {
|
|||||||
HSSFRow r = (HSSFRow)rows.next();
|
HSSFRow r = (HSSFRow)rows.next();
|
||||||
for (Iterator<Cell> cells = r.cellIterator(); cells.hasNext();) {
|
for (Iterator<Cell> cells = r.cellIterator(); cells.hasNext();) {
|
||||||
HSSFCell c = (HSSFCell)cells.next();
|
HSSFCell c = (HSSFCell)cells.next();
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -568,7 +568,7 @@ public final class TestFormulaEvaluatorBugs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private Ptg[] getPtgs(HSSFCell cell) {
|
private Ptg[] getPtgs(HSSFCell cell) {
|
||||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, cell.getCellType());
|
||||||
assertEquals(FormulaRecordAggregate.class, cell.getCellValueRecord().getClass());
|
assertEquals(FormulaRecordAggregate.class, cell.getCellValueRecord().getClass());
|
||||||
FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord();
|
FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord();
|
||||||
FormulaRecord rec = agg.getFormulaRecord();
|
FormulaRecord rec = agg.getFormulaRecord();
|
||||||
|
@ -73,11 +73,11 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
|||||||
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
|
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
|
||||||
for(Row r : sheet) {
|
for(Row r : sheet) {
|
||||||
for(Cell c : r) {
|
for(Cell c : r) {
|
||||||
if(c.getCellTypeEnum() == CellType.FORMULA) {
|
if(c.getCellType() == CellType.FORMULA) {
|
||||||
evaluator.evaluateFormulaCellEnum(c);
|
evaluator.evaluateFormulaCell(c);
|
||||||
|
|
||||||
// For testing - all should be numeric
|
// For testing - all should be numeric
|
||||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(c));
|
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,15 +86,15 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
|||||||
// Check now as expected
|
// Check now as expected
|
||||||
assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
|
assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
|
||||||
assertEquals("SUM(A1:B1)", wb.getSheetAt(0).getRow(0).getCell(2).getCellFormula());
|
assertEquals("SUM(A1:B1)", wb.getSheetAt(0).getRow(0).getCell(2).getCellFormula());
|
||||||
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellTypeEnum());
|
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
|
||||||
|
|
||||||
assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
|
assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
|
||||||
assertEquals("SUM(A2:B2)", wb.getSheetAt(0).getRow(1).getCell(2).getCellFormula());
|
assertEquals("SUM(A2:B2)", wb.getSheetAt(0).getRow(1).getCell(2).getCellFormula());
|
||||||
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellTypeEnum());
|
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
|
||||||
|
|
||||||
assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
|
assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
|
||||||
assertEquals("'S1'!A1", wb.getSheetAt(1).getRow(0).getCell(0).getCellFormula());
|
assertEquals("'S1'!A1", wb.getSheetAt(1).getRow(0).getCell(0).getCellFormula());
|
||||||
assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellTypeEnum());
|
assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
|
||||||
|
|
||||||
|
|
||||||
// Now do the alternate call, which zaps the formulas
|
// Now do the alternate call, which zaps the formulas
|
||||||
@ -104,7 +104,7 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
|||||||
|
|
||||||
for(Row r : sheet) {
|
for(Row r : sheet) {
|
||||||
for(Cell c : r) {
|
for(Cell c : r) {
|
||||||
if(c.getCellTypeEnum() == CellType.FORMULA) {
|
if(c.getCellType() == CellType.FORMULA) {
|
||||||
evaluator.evaluateInCell(c);
|
evaluator.evaluateInCell(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,12 +112,12 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
|
assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0);
|
||||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
|
||||||
|
|
||||||
assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
|
assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
|
||||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
|
||||||
|
|
||||||
assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
|
assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
|
||||||
assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellTypeEnum());
|
assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
|||||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||||
|
|
||||||
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
|
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
|
||||||
fe.evaluateFormulaCellEnum(cellB1);
|
fe.evaluateFormulaCell(cellB1);
|
||||||
|
|
||||||
cellA1.setCellValue(2.5);
|
cellA1.setCellValue(2.5);
|
||||||
fe.notifyUpdateCell(cellA1);
|
fe.notifyUpdateCell(cellA1);
|
||||||
@ -227,10 +227,10 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
|||||||
new HSSFFormulaEvaluator(wb2)
|
new HSSFFormulaEvaluator(wb2)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
eval.evaluateFormulaCellEnum(
|
eval.evaluateFormulaCell(
|
||||||
wb1.getSheetAt(0).getRow(1).getCell(2)
|
wb1.getSheetAt(0).getRow(1).getCell(2)
|
||||||
);
|
);
|
||||||
eval.evaluateFormulaCellEnum(
|
eval.evaluateFormulaCell(
|
||||||
wb1.getSheetAt(0).getRow(1).getCell(4)
|
wb1.getSheetAt(0).getRow(1).getCell(4)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
|||||||
assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
|
assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
|
||||||
|
|
||||||
// Check it evaluates correctly
|
// Check it evaluates correctly
|
||||||
eval.evaluateFormulaCellEnum(cell);
|
eval.evaluateFormulaCell(cell);
|
||||||
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
|
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
|
||||||
|
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
|||||||
new HSSFFormulaEvaluator(wb3)
|
new HSSFFormulaEvaluator(wb3)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
eval.evaluateFormulaCellEnum(cell);
|
eval.evaluateFormulaCell(cell);
|
||||||
assertEquals("In another workbook", cell.getStringCellValue());
|
assertEquals("In another workbook", cell.getStringCellValue());
|
||||||
|
|
||||||
|
|
||||||
@ -310,13 +310,13 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
|||||||
// Check the one referring to the previously existing workbook behaves
|
// Check the one referring to the previously existing workbook behaves
|
||||||
cell = wb4.getSheetAt(0).getRow(1).getCell(40);
|
cell = wb4.getSheetAt(0).getRow(1).getCell(40);
|
||||||
assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
|
assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
|
||||||
eval.evaluateFormulaCellEnum(cell);
|
eval.evaluateFormulaCell(cell);
|
||||||
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
|
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
|
||||||
|
|
||||||
// Now check the newly added reference
|
// Now check the newly added reference
|
||||||
cell = wb4.getSheetAt(0).getRow(1).getCell(42);
|
cell = wb4.getSheetAt(0).getRow(1).getCell(42);
|
||||||
assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
|
assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
|
||||||
eval.evaluateFormulaCellEnum(cell);
|
eval.evaluateFormulaCell(cell);
|
||||||
assertEquals("In another workbook", cell.getStringCellValue());
|
assertEquals("In another workbook", cell.getStringCellValue());
|
||||||
|
|
||||||
wb4.close();
|
wb4.close();
|
||||||
|
@ -151,12 +151,12 @@ public abstract class BaseTestExternalFunctions {
|
|||||||
Cell cell2 = sh.getRow(2).getCell(1);
|
Cell cell2 = sh.getRow(2).getCell(1);
|
||||||
assertEquals("ISODD(2)", cell2.getCellFormula());
|
assertEquals("ISODD(2)", cell2.getCellFormula());
|
||||||
assertEquals(false, evaluator.evaluate(cell2).getBooleanValue());
|
assertEquals(false, evaluator.evaluate(cell2).getBooleanValue());
|
||||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(cell2));
|
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell2));
|
||||||
|
|
||||||
Cell cell3 = sh.getRow(3).getCell(1);
|
Cell cell3 = sh.getRow(3).getCell(1);
|
||||||
assertEquals("ISEVEN(2)", cell3.getCellFormula());
|
assertEquals("ISEVEN(2)", cell3.getCellFormula());
|
||||||
assertEquals(true, evaluator.evaluate(cell3).getBooleanValue());
|
assertEquals(true, evaluator.evaluate(cell3).getBooleanValue());
|
||||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(cell3));
|
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell3));
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
@ -739,7 +739,7 @@ public class TestEvaluationCache extends TestCase {
|
|||||||
|
|
||||||
//calculate
|
//calculate
|
||||||
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
evaluator.evaluateFormulaCellEnum(summaryCell);
|
evaluator.evaluateFormulaCell(summaryCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -779,7 +779,7 @@ public class TestEvaluationCache extends TestCase {
|
|||||||
|
|
||||||
//calculate
|
//calculate
|
||||||
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
evaluator.evaluateFormulaCellEnum(summaryCell);
|
evaluator.evaluateFormulaCell(summaryCell);
|
||||||
assertEquals(8394753.0, summaryCell.getNumericCellValue());
|
assertEquals(8394753.0, summaryCell.getNumericCellValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ public class TestMissingWorkbook extends TestCase {
|
|||||||
Row lARow = lSheet.getRow(0);
|
Row lARow = lSheet.getRow(0);
|
||||||
Cell lA1Cell = lARow.getCell(0);
|
Cell lA1Cell = lARow.getCell(0);
|
||||||
|
|
||||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||||
try {
|
try {
|
||||||
evaluator.evaluateFormulaCellEnum(lA1Cell);
|
evaluator.evaluateFormulaCell(lA1Cell);
|
||||||
fail("Missing external workbook reference exception expected!");
|
fail("Missing external workbook reference exception expected!");
|
||||||
}catch(RuntimeException re) {
|
}catch(RuntimeException re) {
|
||||||
assertTrue("Unexpected exception: " + re, re.getMessage().indexOf(SOURCE_DUMMY_WORKBOOK_FILENAME) != -1);
|
assertTrue("Unexpected exception: " + re, re.getMessage().indexOf(SOURCE_DUMMY_WORKBOOK_FILENAME) != -1);
|
||||||
@ -82,9 +82,9 @@ public class TestMissingWorkbook extends TestCase {
|
|||||||
Cell lB1Cell = lSheet.getRow(1).getCell(0);
|
Cell lB1Cell = lSheet.getRow(1).getCell(0);
|
||||||
Cell lC1Cell = lSheet.getRow(2).getCell(0);
|
Cell lC1Cell = lSheet.getRow(2).getCell(0);
|
||||||
|
|
||||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||||
assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lB1Cell.getCellType());
|
||||||
assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lC1Cell.getCellType());
|
||||||
|
|
||||||
// Check cached values
|
// Check cached values
|
||||||
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||||
@ -95,9 +95,9 @@ public class TestMissingWorkbook extends TestCase {
|
|||||||
FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
|
||||||
evaluator.setIgnoreMissingWorkbooks(true);
|
evaluator.setIgnoreMissingWorkbooks(true);
|
||||||
|
|
||||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(lA1Cell));
|
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(lA1Cell));
|
||||||
assertEquals(CellType.STRING, evaluator.evaluateFormulaCellEnum(lB1Cell));
|
assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(lB1Cell));
|
||||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(lC1Cell));
|
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(lC1Cell));
|
||||||
|
|
||||||
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||||
assertEquals("POI rocks!", lB1Cell.getStringCellValue());
|
assertEquals("POI rocks!", lB1Cell.getStringCellValue());
|
||||||
@ -111,9 +111,9 @@ public class TestMissingWorkbook extends TestCase {
|
|||||||
Cell lB1Cell = lSheet.getRow(1).getCell(0);
|
Cell lB1Cell = lSheet.getRow(1).getCell(0);
|
||||||
Cell lC1Cell = lSheet.getRow(2).getCell(0);
|
Cell lC1Cell = lSheet.getRow(2).getCell(0);
|
||||||
|
|
||||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
|
||||||
assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lB1Cell.getCellType());
|
||||||
assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum());
|
assertEquals(CellType.FORMULA, lC1Cell.getCellType());
|
||||||
|
|
||||||
FormulaEvaluator lMainWorkbookEvaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator lMainWorkbookEvaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
|
||||||
FormulaEvaluator lSourceEvaluator = sourceWorkbook.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator lSourceEvaluator = sourceWorkbook.getCreationHelper().createFormulaEvaluator();
|
||||||
@ -122,9 +122,9 @@ public class TestMissingWorkbook extends TestCase {
|
|||||||
workbooks.put(SOURCE_DUMMY_WORKBOOK_FILENAME, lSourceEvaluator);
|
workbooks.put(SOURCE_DUMMY_WORKBOOK_FILENAME, lSourceEvaluator);
|
||||||
lMainWorkbookEvaluator.setupReferencedWorkbooks(workbooks);
|
lMainWorkbookEvaluator.setupReferencedWorkbooks(workbooks);
|
||||||
|
|
||||||
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lA1Cell));
|
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
|
||||||
assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lB1Cell));
|
assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell));
|
||||||
assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lC1Cell));
|
assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell));
|
||||||
|
|
||||||
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||||
assertEquals("Apache rocks!", lB1Cell.getStringCellValue());
|
assertEquals("Apache rocks!", lB1Cell.getStringCellValue());
|
||||||
|
@ -533,7 +533,7 @@ public class TestWorkbookEvaluator {
|
|||||||
Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
|
Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
|
||||||
|
|
||||||
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
CellType resultCellType = eval.evaluateFormulaCellEnum(D1);
|
CellType resultCellType = eval.evaluateFormulaCell(D1);
|
||||||
|
|
||||||
// Call should modify the contents, but leave the formula intact
|
// Call should modify the contents, but leave the formula intact
|
||||||
assertEquals(CellType.FORMULA, D1.getCellType());
|
assertEquals(CellType.FORMULA, D1.getCellType());
|
||||||
|
@ -66,11 +66,11 @@ public class TestRandBetween extends TestCase {
|
|||||||
|
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
formulaCell.setCellFormula("RANDBETWEEN(1,1)");
|
formulaCell.setCellFormula("RANDBETWEEN(1,1)");
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(1, formulaCell.getNumericCellValue(), 0);
|
assertEquals(1, formulaCell.getNumericCellValue(), 0);
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
formulaCell.setCellFormula("RANDBETWEEN(-1,-1)");
|
formulaCell.setCellFormula("RANDBETWEEN(-1,-1)");
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -86,25 +86,25 @@ public class TestRandBetween extends TestCase {
|
|||||||
topValueCell.setCellValue(0.1);
|
topValueCell.setCellValue(0.1);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(1, formulaCell.getNumericCellValue(), 0);
|
assertEquals(1, formulaCell.getNumericCellValue(), 0);
|
||||||
bottomValueCell.setCellValue(-0.1);
|
bottomValueCell.setCellValue(-0.1);
|
||||||
topValueCell.setCellValue(-0.05);
|
topValueCell.setCellValue(-0.05);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(0, formulaCell.getNumericCellValue(), 0);
|
assertEquals(0, formulaCell.getNumericCellValue(), 0);
|
||||||
bottomValueCell.setCellValue(-1.1);
|
bottomValueCell.setCellValue(-1.1);
|
||||||
topValueCell.setCellValue(-1.05);
|
topValueCell.setCellValue(-1.05);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
||||||
bottomValueCell.setCellValue(-1.1);
|
bottomValueCell.setCellValue(-1.1);
|
||||||
topValueCell.setCellValue(-1.1);
|
topValueCell.setCellValue(-1.1);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public class TestRandBetween extends TestCase {
|
|||||||
topValueCell.setCellType(CellType.BLANK);
|
topValueCell.setCellType(CellType.BLANK);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertTrue(formulaCell.getNumericCellValue() == 0 || formulaCell.getNumericCellValue() == -1);
|
assertTrue(formulaCell.getNumericCellValue() == 0 || formulaCell.getNumericCellValue() == -1);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ public class TestRandBetween extends TestCase {
|
|||||||
topValueCell.setCellValue(1);
|
topValueCell.setCellValue(1);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public class TestRandBetween extends TestCase {
|
|||||||
topValueCell.setCellValue("STRING");
|
topValueCell.setCellValue("STRING");
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ public class TestRandBetween extends TestCase {
|
|||||||
topValueCell.setCellValue("STRING");
|
topValueCell.setCellValue("STRING");
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||||
|
|
||||||
@ -165,14 +165,14 @@ public class TestRandBetween extends TestCase {
|
|||||||
topValueCell.setCellValue(0);
|
topValueCell.setCellValue(0);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||||
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
||||||
bottomValueCell.setCellValue(1);
|
bottomValueCell.setCellValue(1);
|
||||||
topValueCell.setCellType(CellType.BLANK);
|
topValueCell.setCellType(CellType.BLANK);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
|
||||||
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ public class TestRandBetween extends TestCase {
|
|||||||
topValueCell.setCellValue(Double.MAX_VALUE);
|
topValueCell.setCellValue(Double.MAX_VALUE);
|
||||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
evaluator.evaluateFormulaCell(formulaCell);
|
||||||
assertTrue(formulaCell.getNumericCellValue() >= Double.MIN_VALUE && formulaCell.getNumericCellValue() <= Double.MAX_VALUE);
|
assertTrue(formulaCell.getNumericCellValue() >= Double.MIN_VALUE && formulaCell.getNumericCellValue() <= Double.MAX_VALUE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ public final class TestFormulasFromSpreadsheet {
|
|||||||
// iterate across the row for all the evaluation cases
|
// iterate across the row for all the evaluation cases
|
||||||
for (int colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
|
for (int colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
|
||||||
Cell c = formulasRow.getCell(colnum);
|
Cell c = formulasRow.getCell(colnum);
|
||||||
if (c == null || c.getCellTypeEnum() != CellType.FORMULA) {
|
if (c == null || c.getCellType() != CellType.FORMULA) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,27 +187,27 @@ public final class TestFormulasFromSpreadsheet {
|
|||||||
assertNotNull(msg + " - Bad setup data expected value is null", expValue);
|
assertNotNull(msg + " - Bad setup data expected value is null", expValue);
|
||||||
assertNotNull(msg + " - actual value was null", actValue);
|
assertNotNull(msg + " - actual value was null", actValue);
|
||||||
|
|
||||||
final CellType cellType = expValue.getCellTypeEnum();
|
final CellType cellType = expValue.getCellType();
|
||||||
switch (cellType) {
|
switch (cellType) {
|
||||||
case BLANK:
|
case BLANK:
|
||||||
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.BLANK, actValue.getCellType());
|
||||||
break;
|
break;
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
|
||||||
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
|
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.ERROR, actValue.getCellType());
|
||||||
assertEquals(msg, ErrorEval.getText(expValue.getErrorCellValue()), ErrorEval.getText(actValue.getErrorValue()));
|
assertEquals(msg, ErrorEval.getText(expValue.getErrorCellValue()), ErrorEval.getText(actValue.getErrorValue()));
|
||||||
break;
|
break;
|
||||||
case FORMULA: // will never be used, since we will call method after formula evaluation
|
case FORMULA: // will never be used, since we will call method after formula evaluation
|
||||||
fail("Cannot expect formula as result of formula evaluation: " + msg);
|
fail("Cannot expect formula as result of formula evaluation: " + msg);
|
||||||
case NUMERIC:
|
case NUMERIC:
|
||||||
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
|
||||||
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
|
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
|
||||||
break;
|
break;
|
||||||
case STRING:
|
case STRING:
|
||||||
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum());
|
assertEquals(msg, CellType.STRING, actValue.getCellType());
|
||||||
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
|
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -228,14 +228,14 @@ public final class TestFormulasFromSpreadsheet {
|
|||||||
System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
if(cell.getCellType() == CellType.BLANK) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
if(cell.getCellType() == CellType.STRING) {
|
||||||
return cell.getRichStringCellValue().getString();
|
return cell.getRichStringCellValue().getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new AssertionFailedError("Bad cell type for 'function name' column: ("
|
throw new AssertionFailedError("Bad cell type for 'function name' column: ("
|
||||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
currentGroupComment = newMarkerValue;
|
currentGroupComment = newMarkerValue;
|
||||||
}
|
}
|
||||||
HSSFCell evalCell = r.getCell(SS.COLUMN_INDEX_EVALUATION);
|
HSSFCell evalCell = r.getCell(SS.COLUMN_INDEX_EVALUATION);
|
||||||
if (evalCell == null || evalCell.getCellTypeEnum() != CellType.FORMULA) {
|
if (evalCell == null || evalCell.getCellType() != CellType.FORMULA) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String rowComment = getCellTextValue(r, SS.COLUMN_ROW_COMMENT, "row comment");
|
String rowComment = getCellTextValue(r, SS.COLUMN_ROW_COMMENT, "row comment");
|
||||||
@ -153,9 +153,9 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
assertNotNull(msg + " - Bad setup data expected value is null", expectedCell);
|
assertNotNull(msg + " - Bad setup data expected value is null", expectedCell);
|
||||||
assertNotNull(msg + " - actual value was null", actualValue);
|
assertNotNull(msg + " - actual value was null", actualValue);
|
||||||
|
|
||||||
if (expectedCell.getCellTypeEnum() == CellType.ERROR) {
|
if (expectedCell.getCellType() == CellType.ERROR) {
|
||||||
int expectedErrorCode = expectedCell.getErrorCellValue();
|
int expectedErrorCode = expectedCell.getErrorCellValue();
|
||||||
assertEquals(msg, CellType.ERROR, actualValue.getCellTypeEnum());
|
assertEquals(msg, CellType.ERROR, actualValue.getCellType());
|
||||||
assertEquals(msg, ErrorEval.getText(expectedErrorCode), actualValue.formatAsString());
|
assertEquals(msg, ErrorEval.getText(expectedErrorCode), actualValue.formatAsString());
|
||||||
assertEquals(msg, expectedErrorCode, actualValue.getErrorValue());
|
assertEquals(msg, expectedErrorCode, actualValue.getErrorValue());
|
||||||
assertEquals(msg, ErrorEval.getText(expectedErrorCode), ErrorEval.getText(actualValue.getErrorValue()));
|
assertEquals(msg, ErrorEval.getText(expectedErrorCode), ErrorEval.getText(actualValue.getErrorValue()));
|
||||||
@ -163,13 +163,13 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unexpected error
|
// unexpected error
|
||||||
assertNotEquals(msg, CellType.ERROR, actualValue.getCellTypeEnum());
|
assertNotEquals(msg, CellType.ERROR, actualValue.getCellType());
|
||||||
assertNotEquals(msg, formatValue(expectedCell), ErrorEval.getText(actualValue.getErrorValue()));
|
assertNotEquals(msg, formatValue(expectedCell), ErrorEval.getText(actualValue.getErrorValue()));
|
||||||
|
|
||||||
// wrong type error
|
// wrong type error
|
||||||
assertEquals(msg, expectedCell.getCellTypeEnum(), actualValue.getCellTypeEnum());
|
assertEquals(msg, expectedCell.getCellType(), actualValue.getCellType());
|
||||||
|
|
||||||
final CellType expectedCellType = expectedCell.getCellTypeEnum();
|
final CellType expectedCellType = expectedCell.getCellType();
|
||||||
switch (expectedCellType) {
|
switch (expectedCellType) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
assertEquals(msg, expectedCell.getBooleanCellValue(), actualValue.getBooleanValue());
|
assertEquals(msg, expectedCell.getBooleanCellValue(), actualValue.getBooleanValue());
|
||||||
@ -212,25 +212,25 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
|
|||||||
if(cell == null) {
|
if(cell == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellTypeEnum() == CellType.BLANK) {
|
if(cell.getCellType() == CellType.BLANK) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(cell.getCellTypeEnum() == CellType.STRING) {
|
if(cell.getCellType() == CellType.STRING) {
|
||||||
return cell.getRichStringCellValue().getString();
|
return cell.getRichStringCellValue().getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
fail("Bad cell type for '" + columnName + "' column: ("
|
fail("Bad cell type for '" + columnName + "' column: ("
|
||||||
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
|
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatValue(HSSFCell expecedCell) {
|
private static String formatValue(HSSFCell expecedCell) {
|
||||||
switch (expecedCell.getCellTypeEnum()) {
|
switch (expecedCell.getCellType()) {
|
||||||
case BLANK: return "<blank>";
|
case BLANK: return "<blank>";
|
||||||
case BOOLEAN: return Boolean.toString(expecedCell.getBooleanCellValue());
|
case BOOLEAN: return Boolean.toString(expecedCell.getBooleanCellValue());
|
||||||
case NUMERIC: return Double.toString(expecedCell.getNumericCellValue());
|
case NUMERIC: return Double.toString(expecedCell.getNumericCellValue());
|
||||||
case STRING: return expecedCell.getRichStringCellValue().getString();
|
case STRING: return expecedCell.getRichStringCellValue().getString();
|
||||||
default: fail("Unexpected cell type of expected value (" + expecedCell.getCellTypeEnum() + ")");
|
default: fail("Unexpected cell type of expected value (" + expecedCell.getCellType() + ")");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public final class TestDate extends TestCase {
|
|||||||
cell11.setCellFormula(formulaText);
|
cell11.setCellFormula(formulaText);
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
CellValue cv = evaluator.evaluate(cell11);
|
CellValue cv = evaluator.evaluate(cell11);
|
||||||
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
|
if (cv.getCellType() != CellType.NUMERIC) {
|
||||||
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
|
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
|
||||||
}
|
}
|
||||||
double actualValue = cv.getNumberValue();
|
double actualValue = cv.getNumberValue();
|
||||||
|
@ -66,7 +66,7 @@ public final class TestFind {
|
|||||||
cell.setCellFormula(formulaText);
|
cell.setCellFormula(formulaText);
|
||||||
fe.notifyUpdateCell(cell);
|
fe.notifyUpdateCell(cell);
|
||||||
CellValue result = fe.evaluate(cell);
|
CellValue result = fe.evaluate(cell);
|
||||||
assertEquals(result.getCellTypeEnum(), CellType.NUMERIC);
|
assertEquals(result.getCellType(), CellType.NUMERIC);
|
||||||
assertEquals(expectedResult, result.getNumberValue(), 0.0);
|
assertEquals(expectedResult, result.getNumberValue(), 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public final class TestFind {
|
|||||||
cell.setCellFormula(formulaText);
|
cell.setCellFormula(formulaText);
|
||||||
fe.notifyUpdateCell(cell);
|
fe.notifyUpdateCell(cell);
|
||||||
CellValue result = fe.evaluate(cell);
|
CellValue result = fe.evaluate(cell);
|
||||||
assertEquals(result.getCellTypeEnum(), CellType.ERROR);
|
assertEquals(result.getCellType(), CellType.ERROR);
|
||||||
assertEquals(expectedErrorCode.getCode(), result.getErrorValue());
|
assertEquals(expectedErrorCode.getCode(), result.getErrorValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public final class TestFixed {
|
|||||||
cell11.setCellFormula(formulaText);
|
cell11.setCellFormula(formulaText);
|
||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
CellValue cv = evaluator.evaluate(cell11);
|
CellValue cv = evaluator.evaluate(cell11);
|
||||||
assertEquals("Wrong result type: " + cv.formatAsString(), CellType.STRING, cv.getCellTypeEnum());
|
assertEquals("Wrong result type: " + cv.formatAsString(), CellType.STRING, cv.getCellType());
|
||||||
String actualValue = cv.getStringValue();
|
String actualValue = cv.getStringValue();
|
||||||
assertEquals(expectedResult, actualValue);
|
assertEquals(expectedResult, actualValue);
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ public final class TestFixed {
|
|||||||
evaluator.clearAllCachedResultValues();
|
evaluator.clearAllCachedResultValues();
|
||||||
CellValue cv = evaluator.evaluate(cell11);
|
CellValue cv = evaluator.evaluate(cell11);
|
||||||
assertTrue("Wrong result type: " + cv.formatAsString(),
|
assertTrue("Wrong result type: " + cv.formatAsString(),
|
||||||
cv.getCellTypeEnum() == CellType.ERROR
|
cv.getCellType() == CellType.ERROR
|
||||||
&& cv.getErrorValue() == FormulaError.VALUE.getCode());
|
&& cv.getErrorValue() == FormulaError.VALUE.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ public final class TestIndirect {
|
|||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
cell.setCellFormula(formula);
|
cell.setCellFormula(formula);
|
||||||
CellValue cv = fe.evaluate(cell);
|
CellValue cv = fe.evaluate(cell);
|
||||||
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
|
if (cv.getCellType() != CellType.NUMERIC) {
|
||||||
fail("expected numeric cell type but got " + cv.formatAsString());
|
fail("expected numeric cell type but got " + cv.formatAsString());
|
||||||
}
|
}
|
||||||
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
|
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
|
||||||
@ -196,7 +196,7 @@ public final class TestIndirect {
|
|||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
cell.setCellFormula(formula);
|
cell.setCellFormula(formula);
|
||||||
CellValue cv = fe.evaluate(cell);
|
CellValue cv = fe.evaluate(cell);
|
||||||
if (cv.getCellTypeEnum() != CellType.ERROR) {
|
if (cv.getCellType() != CellType.ERROR) {
|
||||||
fail("expected error cell type but got " + cv.formatAsString());
|
fail("expected error cell type but got " + cv.formatAsString());
|
||||||
}
|
}
|
||||||
int expCode = expectedResult.getErrorCode();
|
int expCode = expectedResult.getErrorCode();
|
||||||
|
@ -81,7 +81,7 @@ public final class TestIrr extends TestCase {
|
|||||||
|
|
||||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cell);
|
fe.evaluateFormulaCell(cell);
|
||||||
double res = cell.getNumericCellValue();
|
double res = cell.getNumericCellValue();
|
||||||
assertEquals(0.143d, Math.round(res * 1000d) / 1000d);
|
assertEquals(0.143d, Math.round(res * 1000d) / 1000d);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ public final class TestMirr extends TestCase {
|
|||||||
|
|
||||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cell);
|
fe.evaluateFormulaCell(cell);
|
||||||
double res = cell.getNumericCellValue();
|
double res = cell.getNumericCellValue();
|
||||||
assertEquals(0.18736225093, res, 0.00000001);
|
assertEquals(0.18736225093, res, 0.00000001);
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ public final class TestMirr extends TestCase {
|
|||||||
private static void assertFormulaResult(CellValue cv, HSSFCell cell) {
|
private static void assertFormulaResult(CellValue cv, HSSFCell cell) {
|
||||||
double actualValue = cv.getNumberValue();
|
double actualValue = cv.getNumberValue();
|
||||||
double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
|
double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
|
||||||
assertEquals("Invalid formula result: " + cv, CellType.NUMERIC, cv.getCellTypeEnum());
|
assertEquals("Invalid formula result: " + cv, CellType.NUMERIC, cv.getCellType());
|
||||||
assertEquals(expectedValue, actualValue, 1E-8);
|
assertEquals(expectedValue, actualValue, 1E-8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public final class TestNpv extends TestCase {
|
|||||||
// Enumeration
|
// Enumeration
|
||||||
cell.setCellFormula("NPV(A2, A4,A5,A6,A7,A8)+A3");
|
cell.setCellFormula("NPV(A2, A4,A5,A6,A7,A8)+A3");
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cell);
|
fe.evaluateFormulaCell(cell);
|
||||||
double res = cell.getNumericCellValue();
|
double res = cell.getNumericCellValue();
|
||||||
assertEquals(1922.06d, Math.round(res * 100d) / 100d);
|
assertEquals(1922.06d, Math.round(res * 100d) / 100d);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public final class TestNpv extends TestCase {
|
|||||||
cell.setCellFormula("NPV(A2, A4:A8)+A3");
|
cell.setCellFormula("NPV(A2, A4:A8)+A3");
|
||||||
|
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cell);
|
fe.evaluateFormulaCell(cell);
|
||||||
res = cell.getNumericCellValue();
|
res = cell.getNumericCellValue();
|
||||||
assertEquals(1922.06d, Math.round(res * 100d) / 100d);
|
assertEquals(1922.06d, Math.round(res * 100d) / 100d);
|
||||||
}
|
}
|
||||||
|
@ -96,9 +96,9 @@ public final class TestExternalNameReference extends TestCase {
|
|||||||
HSSFCell ccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell((int)cellRef.getCol());
|
HSSFCell ccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell((int)cellRef.getCol());
|
||||||
cellRef = new CellReference(wb.getName("TOTALCOST").getRefersToFormula());
|
cellRef = new CellReference(wb.getName("TOTALCOST").getRefersToFormula());
|
||||||
HSSFCell tccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell((int)cellRef.getCol());
|
HSSFCell tccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell((int)cellRef.getCol());
|
||||||
evaluator.evaluateFormulaCellEnum(uccell);
|
evaluator.evaluateFormulaCell(uccell);
|
||||||
evaluator.evaluateFormulaCellEnum(ccell);
|
evaluator.evaluateFormulaCell(ccell);
|
||||||
evaluator.evaluateFormulaCellEnum(tccell);
|
evaluator.evaluateFormulaCell(tccell);
|
||||||
assertEquals(NEW_PART_COST, uccell.getNumericCellValue());
|
assertEquals(NEW_PART_COST, uccell.getNumericCellValue());
|
||||||
assertEquals(NEW_PART_COST*NEW_QUANT, ccell.getNumericCellValue());
|
assertEquals(NEW_PART_COST*NEW_QUANT, ccell.getNumericCellValue());
|
||||||
assertEquals(NEW_PART_COST*NEW_QUANT*MARKUP_COST_2, tccell.getNumericCellValue());
|
assertEquals(NEW_PART_COST*NEW_QUANT*MARKUP_COST_2, tccell.getNumericCellValue());
|
||||||
|
@ -864,7 +864,7 @@ public abstract class BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
private Cell evaluateCell(Workbook wb, Cell c) {
|
private Cell evaluateCell(Workbook wb, Cell c) {
|
||||||
Sheet s = c.getSheet();
|
Sheet s = c.getSheet();
|
||||||
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCellEnum(c);
|
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(c);
|
||||||
return s.getRow(c.getRowIndex()).getCell(c.getColumnIndex());
|
return s.getRow(c.getRowIndex()).getCell(c.getColumnIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,8 +945,8 @@ public abstract class BaseTestBugzillaIssues {
|
|||||||
|
|
||||||
|
|
||||||
// Try to evaluate, with the other file
|
// Try to evaluate, with the other file
|
||||||
evaluator.evaluateFormulaCellEnum(c1);
|
evaluator.evaluateFormulaCell(c1);
|
||||||
evaluator.evaluateFormulaCellEnum(c2);
|
evaluator.evaluateFormulaCell(c2);
|
||||||
|
|
||||||
assertEquals(otherCellText, c1.getStringCellValue());
|
assertEquals(otherCellText, c1.getStringCellValue());
|
||||||
assertEquals(otherCellText, c2.getStringCellValue());
|
assertEquals(otherCellText, c2.getStringCellValue());
|
||||||
@ -1153,8 +1153,8 @@ public abstract class BaseTestBugzillaIssues {
|
|||||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellType());
|
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellType());
|
||||||
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellType());
|
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellType());
|
||||||
fe.evaluateFormulaCellEnum(cfn);
|
fe.evaluateFormulaCell(cfn);
|
||||||
fe.evaluateFormulaCellEnum(cfs);
|
fe.evaluateFormulaCell(cfs);
|
||||||
|
|
||||||
// Now test
|
// Now test
|
||||||
assertEquals(CellType.NUMERIC, cn.getCellType());
|
assertEquals(CellType.NUMERIC, cn.getCellType());
|
||||||
@ -1282,17 +1282,17 @@ public abstract class BaseTestBugzillaIssues {
|
|||||||
// Check read ok, and re-evaluate fine
|
// Check read ok, and re-evaluate fine
|
||||||
cell = row.getCell(5);
|
cell = row.getCell(5);
|
||||||
assertEquals("ab", cell.getStringCellValue());
|
assertEquals("ab", cell.getStringCellValue());
|
||||||
ev.evaluateFormulaCellEnum(cell);
|
ev.evaluateFormulaCell(cell);
|
||||||
assertEquals("ab", cell.getStringCellValue());
|
assertEquals("ab", cell.getStringCellValue());
|
||||||
|
|
||||||
cell = row.getCell(6);
|
cell = row.getCell(6);
|
||||||
assertEquals("empty", cell.getStringCellValue());
|
assertEquals("empty", cell.getStringCellValue());
|
||||||
ev.evaluateFormulaCellEnum(cell);
|
ev.evaluateFormulaCell(cell);
|
||||||
assertEquals("empty", cell.getStringCellValue());
|
assertEquals("empty", cell.getStringCellValue());
|
||||||
|
|
||||||
cell = row.getCell(7);
|
cell = row.getCell(7);
|
||||||
assertEquals("ab", cell.getStringCellValue());
|
assertEquals("ab", cell.getStringCellValue());
|
||||||
ev.evaluateFormulaCellEnum(cell);
|
ev.evaluateFormulaCell(cell);
|
||||||
assertEquals("ab", cell.getStringCellValue());
|
assertEquals("ab", cell.getStringCellValue());
|
||||||
wb2.close();
|
wb2.close();
|
||||||
}
|
}
|
||||||
|
@ -503,7 +503,7 @@ public abstract class BaseTestCell {
|
|||||||
|
|
||||||
FormulaEvaluator fe = cellA1.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = cellA1.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||||
|
|
||||||
fe.evaluateFormulaCellEnum(cellA1);
|
fe.evaluateFormulaCell(cellA1);
|
||||||
assertEquals("abc", cellA1.getStringCellValue());
|
assertEquals("abc", cellA1.getStringCellValue());
|
||||||
|
|
||||||
fe.evaluateInCell(cellA1);
|
fe.evaluateInCell(cellA1);
|
||||||
@ -526,14 +526,14 @@ public abstract class BaseTestCell {
|
|||||||
|
|
||||||
cellA1.setCellFormula("\"DEF\"");
|
cellA1.setCellFormula("\"DEF\"");
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cellA1);
|
fe.evaluateFormulaCell(cellA1);
|
||||||
assertEquals("DEF", cellA1.getStringCellValue());
|
assertEquals("DEF", cellA1.getStringCellValue());
|
||||||
cellA1.setCellType(CellType.STRING);
|
cellA1.setCellType(CellType.STRING);
|
||||||
assertEquals("DEF", cellA1.getStringCellValue());
|
assertEquals("DEF", cellA1.getStringCellValue());
|
||||||
|
|
||||||
cellA1.setCellFormula("25.061");
|
cellA1.setCellFormula("25.061");
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cellA1);
|
fe.evaluateFormulaCell(cellA1);
|
||||||
confirmCannotReadString(cellA1);
|
confirmCannotReadString(cellA1);
|
||||||
assertEquals(25.061, cellA1.getNumericCellValue(), 0.0);
|
assertEquals(25.061, cellA1.getNumericCellValue(), 0.0);
|
||||||
cellA1.setCellType(CellType.STRING);
|
cellA1.setCellType(CellType.STRING);
|
||||||
@ -541,7 +541,7 @@ public abstract class BaseTestCell {
|
|||||||
|
|
||||||
cellA1.setCellFormula("TRUE");
|
cellA1.setCellFormula("TRUE");
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cellA1);
|
fe.evaluateFormulaCell(cellA1);
|
||||||
confirmCannotReadString(cellA1);
|
confirmCannotReadString(cellA1);
|
||||||
assertEquals(true, cellA1.getBooleanCellValue());
|
assertEquals(true, cellA1.getBooleanCellValue());
|
||||||
cellA1.setCellType(CellType.STRING);
|
cellA1.setCellType(CellType.STRING);
|
||||||
@ -549,7 +549,7 @@ public abstract class BaseTestCell {
|
|||||||
|
|
||||||
cellA1.setCellFormula("#NAME?");
|
cellA1.setCellFormula("#NAME?");
|
||||||
fe.clearAllCachedResultValues();
|
fe.clearAllCachedResultValues();
|
||||||
fe.evaluateFormulaCellEnum(cellA1);
|
fe.evaluateFormulaCell(cellA1);
|
||||||
confirmCannotReadString(cellA1);
|
confirmCannotReadString(cellA1);
|
||||||
assertEquals(FormulaError.NAME, forInt(cellA1.getErrorCellValue()));
|
assertEquals(FormulaError.NAME, forInt(cellA1.getErrorCellValue()));
|
||||||
cellA1.setCellType(CellType.STRING);
|
cellA1.setCellType(CellType.STRING);
|
||||||
@ -819,7 +819,7 @@ public abstract class BaseTestCell {
|
|||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
Cell cell = row.createCell(0);
|
Cell cell = row.createCell(0);
|
||||||
cell.setCellFormula("SQRT(-1)");
|
cell.setCellFormula("SQRT(-1)");
|
||||||
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCellEnum(cell);
|
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(cell);
|
||||||
assertEquals(36, cell.getErrorCellValue());
|
assertEquals(36, cell.getErrorCellValue());
|
||||||
} finally {
|
} finally {
|
||||||
wb.close();
|
wb.close();
|
||||||
|
@ -57,8 +57,8 @@ public abstract class BaseTestFormulaEvaluator {
|
|||||||
|
|
||||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
|
|
||||||
fe.evaluateFormulaCellEnum(c1);
|
fe.evaluateFormulaCell(c1);
|
||||||
fe.evaluateFormulaCellEnum(c2);
|
fe.evaluateFormulaCell(c2);
|
||||||
|
|
||||||
assertEquals(6.0, c1.getNumericCellValue(), 0.0001);
|
assertEquals(6.0, c1.getNumericCellValue(), 0.0001);
|
||||||
assertEquals(5.0, c2.getNumericCellValue(), 0.0001);
|
assertEquals(5.0, c2.getNumericCellValue(), 0.0001);
|
||||||
@ -98,10 +98,10 @@ public abstract class BaseTestFormulaEvaluator {
|
|||||||
// Evaluate and test
|
// Evaluate and test
|
||||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
|
|
||||||
fe.evaluateFormulaCellEnum(c1);
|
fe.evaluateFormulaCell(c1);
|
||||||
fe.evaluateFormulaCellEnum(c2);
|
fe.evaluateFormulaCell(c2);
|
||||||
fe.evaluateFormulaCellEnum(c3);
|
fe.evaluateFormulaCell(c3);
|
||||||
fe.evaluateFormulaCellEnum(c4);
|
fe.evaluateFormulaCell(c4);
|
||||||
|
|
||||||
assertEquals(3.6, c1.getNumericCellValue(), 0.0001);
|
assertEquals(3.6, c1.getNumericCellValue(), 0.0001);
|
||||||
assertEquals(17.5, c2.getNumericCellValue(), 0.0001);
|
assertEquals(17.5, c2.getNumericCellValue(), 0.0001);
|
||||||
@ -290,7 +290,7 @@ public abstract class BaseTestFormulaEvaluator {
|
|||||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||||
|
|
||||||
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
|
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
|
||||||
fe.evaluateFormulaCellEnum(cellB1);
|
fe.evaluateFormulaCell(cellB1);
|
||||||
|
|
||||||
cellA1.setCellValue(2.5);
|
cellA1.setCellValue(2.5);
|
||||||
fe.notifyUpdateCell(cellA1);
|
fe.notifyUpdateCell(cellA1);
|
||||||
|
@ -344,8 +344,8 @@ public abstract class BaseTestSheetAutosizeColumn {
|
|||||||
Sheet sheet = workbook.getSheetAt(i);
|
Sheet sheet = workbook.getSheetAt(i);
|
||||||
for (Row r : sheet) {
|
for (Row r : sheet) {
|
||||||
for (Cell c : r) {
|
for (Cell c : r) {
|
||||||
if (c.getCellTypeEnum() == CellType.FORMULA){
|
if (c.getCellType() == CellType.FORMULA){
|
||||||
eval.evaluateFormulaCellEnum(c);
|
eval.evaluateFormulaCell(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user