bug 59791: FormulaEvaluator#evaluateFormulaCell(Cell) should return an integer for backwards compatibility
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751261 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
034d3cfcca
commit
268c5deeb2
@ -36,6 +36,7 @@ import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
/**
|
||||
* Evaluates formula cells.<p/>
|
||||
@ -213,15 +214,37 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
* @return -1 for non-formula cells, or the type of the <em>formula result</em>
|
||||
*/
|
||||
@Override
|
||||
public CellType evaluateFormulaCell(Cell cell) {
|
||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
return CellType._UNINITIALIZED;
|
||||
}
|
||||
CellValue cv = evaluateFormulaCellValue(cell);
|
||||
// cell remains a formula cell, but the cached value is changed
|
||||
setCellValue(cell, cv);
|
||||
return cv.getCellType();
|
||||
public int evaluateFormulaCell(Cell cell) {
|
||||
return evaluateFormulaCellEnum(cell).getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* If cell contains formula, it evaluates the formula, and saves the result of the formula. The
|
||||
* cell remains as a formula cell. If the cell does not contain formula, this method returns -1
|
||||
* and leaves the cell unchanged.
|
||||
*
|
||||
* Note that the type of the <em>formula result</em> is returned, so you know what kind of
|
||||
* cached formula result is also stored with the formula.
|
||||
* <pre>
|
||||
* int evaluatedCellType = evaluator.evaluateFormulaCell(cell);
|
||||
* </pre>
|
||||
* Be aware that your cell will hold both the formula, and the result. If you want the cell
|
||||
* replaced with the result of the formula, use {@link #evaluateInCell(org.apache.poi.ss.usermodel.Cell)}
|
||||
* @param cell The cell to evaluate
|
||||
* @return -1 for non-formula cells, or the type of the <em>formula result</em>
|
||||
* @deprecated POI 3.15 beta 3
|
||||
*/
|
||||
@Internal
|
||||
@Override
|
||||
public CellType evaluateFormulaCellEnum(Cell cell) {
|
||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
return CellType._UNINITIALIZED;
|
||||
}
|
||||
CellValue cv = evaluateFormulaCellValue(cell);
|
||||
// cell remains a formula cell, but the cached value is changed
|
||||
setCellValue(cell, cv);
|
||||
return cv.getCellType();
|
||||
}
|
||||
|
||||
/**
|
||||
* If cell contains formula, it evaluates the formula, and
|
||||
@ -236,7 +259,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
* </pre>
|
||||
* Be aware that your cell value will be changed to hold the
|
||||
* result of the formula. If you simply want the formula
|
||||
* value computed for you, use {@link #evaluateFormulaCell(Cell)}}
|
||||
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}}
|
||||
*/
|
||||
@Override
|
||||
public HSSFCell evaluateInCell(Cell cell) {
|
||||
@ -331,7 +354,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
|
||||
for(Row r : sheet) {
|
||||
for (Cell c : r) {
|
||||
if (c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
evaluator.evaluateFormulaCell(c);
|
||||
evaluator.evaluateFormulaCellEnum(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
* 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
|
||||
* example in {@link org.apache.poi.ss.usermodel.FormulaEvaluator#evaluateFormulaCell(org.apache.poi.ss.usermodel.Cell)})
|
||||
* example in {@link org.apache.poi.ss.usermodel.FormulaEvaluator#evaluateFormulaCellEnum(org.apache.poi.ss.usermodel.Cell)})
|
||||
* 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
|
||||
* unpredictably (typically ignoring the update).</li>
|
||||
|
@ -884,7 +884,7 @@ public class DataFormatter implements Observer {
|
||||
if (evaluator == null) {
|
||||
return cell.getCellFormula();
|
||||
}
|
||||
cellType = evaluator.evaluateFormulaCell(cell);
|
||||
cellType = evaluator.evaluateFormulaCellEnum(cell);
|
||||
}
|
||||
switch (cellType) {
|
||||
case NUMERIC :
|
||||
|
@ -19,6 +19,8 @@ package org.apache.poi.ss.usermodel;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
/**
|
||||
* Evaluates formula cells.<p/>
|
||||
*
|
||||
@ -96,10 +98,36 @@ public interface FormulaEvaluator {
|
||||
* the result of the formula, use {@link #evaluateInCell(Cell)}
|
||||
* @param cell The cell to evaluate
|
||||
* @return The type of the formula result, i.e. -1 if the cell is not a formula,
|
||||
* or one of CellType.NUMERIC, CellType.STRING, CellType.BOOLEAN, CellType.ERROR
|
||||
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
|
||||
* Note: the cell's type remains as CellType.FORMULA however.
|
||||
*/
|
||||
CellType evaluateFormulaCell(Cell cell);
|
||||
int evaluateFormulaCell(Cell cell);
|
||||
|
||||
/**
|
||||
* If cell contains formula, it evaluates the formula,
|
||||
* and saves the result of the formula. The cell
|
||||
* remains as a formula cell.
|
||||
* Else if cell does not contain formula, this method leaves
|
||||
* the cell unchanged.
|
||||
* Note that the type of the formula result is returned,
|
||||
* so you know what kind of value is also stored with
|
||||
* the formula.
|
||||
* <pre>
|
||||
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
|
||||
* </pre>
|
||||
* Be aware that your cell will hold both the formula,
|
||||
* and the result. If you want the cell replaced with
|
||||
* the result of the formula, use {@link #evaluateInCell(Cell)}
|
||||
* @param cell The cell to evaluate
|
||||
* @return The type of the formula result, i.e. -1 if the cell is not a formula,
|
||||
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
|
||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}
|
||||
* Note: the cell's type remains as CellType.FORMULA however.
|
||||
* @deprecated POI 3.15 beta 3. Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||
*/
|
||||
@Internal
|
||||
CellType evaluateFormulaCellEnum(Cell cell);
|
||||
|
||||
/**
|
||||
* If cell contains formula, it evaluates the formula, and
|
||||
@ -114,7 +142,7 @@ public interface FormulaEvaluator {
|
||||
* </pre>
|
||||
* Be aware that your cell value will be changed to hold the
|
||||
* result of the formula. If you simply want the formula
|
||||
* value computed for you, use {@link #evaluateFormulaCell(Cell)}
|
||||
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}
|
||||
* @param cell
|
||||
*/
|
||||
Cell evaluateInCell(Cell cell);
|
||||
|
@ -69,18 +69,34 @@ public class SheetUtil {
|
||||
* See Bugzilla #50021
|
||||
*/
|
||||
private static final FormulaEvaluator dummyEvaluator = new FormulaEvaluator(){
|
||||
@Override
|
||||
public void clearAllCachedResultValues(){}
|
||||
@Override
|
||||
public void notifySetFormula(Cell cell) {}
|
||||
@Override
|
||||
public void notifyDeleteCell(Cell cell) {}
|
||||
@Override
|
||||
public void notifyUpdateCell(Cell cell) {}
|
||||
@Override
|
||||
public CellValue evaluate(Cell cell) {return null; }
|
||||
@Override
|
||||
public Cell evaluateInCell(Cell cell) { return null; }
|
||||
@Override
|
||||
public void setupReferencedWorkbooks(Map<String, FormulaEvaluator> workbooks) {}
|
||||
@Override
|
||||
public void setDebugEvaluationOutputForNextEval(boolean value) {}
|
||||
@Override
|
||||
public void setIgnoreMissingWorkbooks(boolean ignore) {}
|
||||
|
||||
@Override
|
||||
public void evaluateAll() {}
|
||||
public CellType evaluateFormulaCell(Cell cell) {
|
||||
@Override
|
||||
public int evaluateFormulaCell(Cell cell) {
|
||||
return cell.getCachedFormulaResultType();
|
||||
}
|
||||
/** @deprecated POI 3.15 beta 3. Will be deleted when we make the CellType enum transition. See bug 59791. */
|
||||
@Internal
|
||||
@Override
|
||||
public CellType evaluateFormulaCellEnum(Cell cell) {
|
||||
return cell.getCachedFormulaResultTypeEnum();
|
||||
}
|
||||
};
|
||||
|
@ -85,7 +85,7 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
||||
* </pre>
|
||||
* Be aware that your cell value will be changed to hold the
|
||||
* result of the formula. If you simply want the formula
|
||||
* value computed for you, use {@link #evaluateFormulaCell(org.apache.poi.ss.usermodel.Cell)} }
|
||||
* value computed for you, use {@link #evaluateFormulaCellEnum(org.apache.poi.ss.usermodel.Cell)} }
|
||||
*/
|
||||
public SXSSFCell evaluateInCell(Cell cell) {
|
||||
doEvaluateInCell(cell);
|
||||
@ -122,7 +122,7 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
||||
for (Row r : sheet) {
|
||||
for (Cell c : r) {
|
||||
if (c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.CellValue;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
/**
|
||||
* Internal POI use only - parent of XSSF and SXSSF formula evaluators
|
||||
@ -112,7 +113,31 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work
|
||||
* @param cell The cell to evaluate
|
||||
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
|
||||
*/
|
||||
public CellType evaluateFormulaCell(Cell cell) {
|
||||
public int evaluateFormulaCell(Cell cell) {
|
||||
return evaluateFormulaCellEnum(cell).getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* If cell contains formula, it evaluates the formula,
|
||||
* and saves the result of the formula. The cell
|
||||
* remains as a formula cell.
|
||||
* Else if cell does not contain formula, this method leaves
|
||||
* the cell unchanged.
|
||||
* Note that the type of the formula result is returned,
|
||||
* so you know what kind of value is also stored with
|
||||
* the formula.
|
||||
* <pre>
|
||||
* int evaluatedCellType = evaluator.evaluateFormulaCell(cell);
|
||||
* </pre>
|
||||
* Be aware that your cell will hold both the formula,
|
||||
* and the result. If you want the cell replaced with
|
||||
* the result of the formula, use {@link #evaluate(org.apache.poi.ss.usermodel.Cell)} }
|
||||
* @param cell The cell to evaluate
|
||||
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however)
|
||||
* @deprecated POI 3.15 beta 3. Will be deleted when we make the CellType enum transition. See bug 59791.
|
||||
*/
|
||||
@Internal
|
||||
public CellType evaluateFormulaCellEnum(Cell cell) {
|
||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
|
||||
return CellType._UNINITIALIZED;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
|
||||
* </pre>
|
||||
* Be aware that your cell value will be changed to hold the
|
||||
* result of the formula. If you simply want the formula
|
||||
* value computed for you, use {@link #evaluateFormulaCell(org.apache.poi.ss.usermodel.Cell)} }
|
||||
* value computed for you, use {@link #evaluateFormulaCellEnum(org.apache.poi.ss.usermodel.Cell)} }
|
||||
* @param cell
|
||||
*/
|
||||
public XSSFCell evaluateInCell(Cell cell) {
|
||||
|
@ -106,7 +106,7 @@ public final class TestSXSSFFormulaEvaluation {
|
||||
|
||||
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
|
||||
try {
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
fail("Evaluate shouldn't work, as reference outside the window");
|
||||
} catch(SXSSFFormulaEvaluator.RowFlushedException e) {
|
||||
// Expected
|
||||
@ -152,7 +152,7 @@ public final class TestSXSSFFormulaEvaluation {
|
||||
c.setCellFormula("A1*2");
|
||||
|
||||
assertEquals(0, (int)c.getNumericCellValue());
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
assertEquals(3, (int)c.getNumericCellValue());
|
||||
|
||||
wb.close();
|
||||
@ -168,12 +168,12 @@ public final class TestSXSSFFormulaEvaluation {
|
||||
SXSSFCell c = s.createRow(0).createCell(0);
|
||||
c.setCellFormula("1+2");
|
||||
assertEquals(0, (int)c.getNumericCellValue());
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
assertEquals(3, (int)c.getNumericCellValue());
|
||||
|
||||
c = s.createRow(1).createCell(0);
|
||||
c.setCellFormula("CONCATENATE(\"hello\",\" \",\"world\")");
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
assertEquals("hello world", c.getStringCellValue());
|
||||
|
||||
wb.close();
|
||||
|
@ -663,14 +663,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals(3.0, c.getNumericCellValue(), 0);
|
||||
|
||||
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||
formulaEvaluator.evaluateFormulaCell(c);
|
||||
formulaEvaluator.evaluateFormulaCellEnum(c);
|
||||
|
||||
assertEquals("SUM(\n1,2\n)", c.getCellFormula());
|
||||
assertEquals(3.0, c.getNumericCellValue(), 0);
|
||||
|
||||
// For 51875
|
||||
Cell b3 = s.getRow(2).getCell(1);
|
||||
formulaEvaluator.evaluateFormulaCell(b3);
|
||||
formulaEvaluator.evaluateFormulaCellEnum(b3);
|
||||
assertEquals("B1+B2", b3.getCellFormula()); // The newline is lost for shared formulas
|
||||
assertEquals(3.0, b3.getNumericCellValue(), 0);
|
||||
|
||||
@ -1375,8 +1375,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Try evaluating both
|
||||
XSSFFormulaEvaluator eval = new XSSFFormulaEvaluator(wb);
|
||||
eval.evaluateFormulaCell(c1);
|
||||
eval.evaluateFormulaCell(c2);
|
||||
eval.evaluateFormulaCellEnum(c1);
|
||||
eval.evaluateFormulaCellEnum(c2);
|
||||
|
||||
assertEquals(20.0, c1.getNumericCellValue(), 0);
|
||||
assertEquals(20.0, c2.getNumericCellValue(), 0);
|
||||
@ -2959,7 +2959,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
cell = row.getCell(1);
|
||||
|
||||
assertEquals(CellType.BLANK, cell.getCellTypeEnum());
|
||||
assertEquals(CellType._UNINITIALIZED, evaluator.evaluateFormulaCell(cell));
|
||||
assertEquals(CellType._UNINITIALIZED, evaluator.evaluateFormulaCellEnum(cell));
|
||||
|
||||
// A3
|
||||
row = worksheet.getRow(2);
|
||||
@ -2967,7 +2967,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("IF(ISBLANK(B3),\"\",B3)", cell.getCellFormula());
|
||||
assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(cell));
|
||||
assertEquals(CellType.STRING, evaluator.evaluateFormulaCellEnum(cell));
|
||||
CellValue value = evaluator.evaluate(cell);
|
||||
assertEquals("", value.getStringValue());
|
||||
|
||||
@ -2977,7 +2977,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
|
||||
assertEquals("COUNTBLANK(A1:A4)", cell.getCellFormula());
|
||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(cell));
|
||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(cell));
|
||||
value = evaluator.evaluate(cell);
|
||||
assertEquals(1.0, value.getNumberValue(), 0.1);
|
||||
|
||||
|
@ -488,7 +488,7 @@ public final class TestXSSFFormulaParser {
|
||||
for (Cell cell : row) {
|
||||
if (cell.getCellTypeEnum() == CellType.FORMULA) {
|
||||
try {
|
||||
evaluator.evaluateFormulaCell(cell);
|
||||
evaluator.evaluateFormulaCellEnum(cell);
|
||||
} catch (Exception e) {
|
||||
CellReference cellRef = new CellReference(cell.getRowIndex(), cell.getColumnIndex());
|
||||
throw new RuntimeException("error at: " + cellRef.toString(), e);
|
||||
|
@ -1118,9 +1118,9 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Now evaluate, they should all be changed
|
||||
HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb1);
|
||||
eval.evaluateFormulaCell(c1);
|
||||
eval.evaluateFormulaCell(c2);
|
||||
eval.evaluateFormulaCell(c3);
|
||||
eval.evaluateFormulaCellEnum(c1);
|
||||
eval.evaluateFormulaCellEnum(c2);
|
||||
eval.evaluateFormulaCellEnum(c3);
|
||||
|
||||
// Check that the cells now contain
|
||||
// the correct values
|
||||
@ -2389,7 +2389,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||
|
||||
// Check the evaluated result
|
||||
HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
assertEquals(4.0, c.getNumericCellValue(), 0);
|
||||
wb.close();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class TestExternalReferenceChange extends TestCase {
|
||||
new String[]{MAIN_WORKBOOK_FILENAME, SOURCE_WORKBOOK_FILENAME},
|
||||
new HSSFFormulaEvaluator[] {lMainWorkbookEvaluator, lSourceEvaluator});
|
||||
|
||||
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
|
||||
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lA1Cell));
|
||||
|
||||
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||
|
||||
|
@ -287,7 +287,7 @@ public final class TestFormulaEvaluatorBugs {
|
||||
HSSFRow r = (HSSFRow)rows.next();
|
||||
for (Iterator<Cell> cells = r.cellIterator(); cells.hasNext();) {
|
||||
HSSFCell c = (HSSFCell)cells.next();
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,10 +78,10 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
|
||||
for(Iterator cit = r.cellIterator(); cit.hasNext();) {
|
||||
HSSFCell c = (HSSFCell)cit.next();
|
||||
if(c.getCellTypeEnum() == CellType.FORMULA) {
|
||||
evaluator.evaluateFormulaCell(c);
|
||||
evaluator.evaluateFormulaCellEnum(c);
|
||||
|
||||
// For testing - all should be numeric
|
||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(c));
|
||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||
|
||||
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
|
||||
fe.evaluateFormulaCell(cellB1);
|
||||
fe.evaluateFormulaCellEnum(cellB1);
|
||||
|
||||
cellA1.setCellValue(2.5);
|
||||
fe.notifyUpdateCell(cellA1);
|
||||
@ -227,10 +227,10 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
||||
new HSSFFormulaEvaluator(wb2)
|
||||
}
|
||||
);
|
||||
eval.evaluateFormulaCell(
|
||||
eval.evaluateFormulaCellEnum(
|
||||
wb1.getSheetAt(0).getRow(1).getCell(2)
|
||||
);
|
||||
eval.evaluateFormulaCell(
|
||||
eval.evaluateFormulaCellEnum(
|
||||
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());
|
||||
|
||||
// Check it evaluates correctly
|
||||
eval.evaluateFormulaCell(cell);
|
||||
eval.evaluateFormulaCellEnum(cell);
|
||||
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
|
||||
new HSSFFormulaEvaluator(wb3)
|
||||
}
|
||||
);
|
||||
eval.evaluateFormulaCell(cell);
|
||||
eval.evaluateFormulaCellEnum(cell);
|
||||
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
|
||||
cell = wb4.getSheetAt(0).getRow(1).getCell(40);
|
||||
assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
|
||||
eval.evaluateFormulaCell(cell);
|
||||
eval.evaluateFormulaCellEnum(cell);
|
||||
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
|
||||
|
||||
// Now check the newly added reference
|
||||
cell = wb4.getSheetAt(0).getRow(1).getCell(42);
|
||||
assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
|
||||
eval.evaluateFormulaCell(cell);
|
||||
eval.evaluateFormulaCellEnum(cell);
|
||||
assertEquals("In another workbook", cell.getStringCellValue());
|
||||
|
||||
wb4.close();
|
||||
|
@ -149,12 +149,12 @@ public abstract class BaseTestExternalFunctions {
|
||||
Cell cell2 = sh.getRow(2).getCell(1);
|
||||
assertEquals("ISODD(2)", cell2.getCellFormula());
|
||||
assertEquals(false, evaluator.evaluate(cell2).getBooleanValue());
|
||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell2));
|
||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(cell2));
|
||||
|
||||
Cell cell3 = sh.getRow(3).getCell(1);
|
||||
assertEquals("ISEVEN(2)", cell3.getCellFormula());
|
||||
assertEquals(true, evaluator.evaluate(cell3).getBooleanValue());
|
||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell3));
|
||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(cell3));
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
@ -730,7 +730,7 @@ public class TestEvaluationCache extends TestCase {
|
||||
|
||||
//calculate
|
||||
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||
evaluator.evaluateFormulaCell(summaryCell);
|
||||
evaluator.evaluateFormulaCellEnum(summaryCell);
|
||||
}
|
||||
|
||||
|
||||
@ -770,7 +770,7 @@ public class TestEvaluationCache extends TestCase {
|
||||
|
||||
//calculate
|
||||
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
|
||||
evaluator.evaluateFormulaCell(summaryCell);
|
||||
evaluator.evaluateFormulaCellEnum(summaryCell);
|
||||
assertEquals(8394753.0, summaryCell.getNumericCellValue());
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class TestMissingWorkbook extends TestCase {
|
||||
|
||||
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
|
||||
try {
|
||||
evaluator.evaluateFormulaCell(lA1Cell);
|
||||
evaluator.evaluateFormulaCellEnum(lA1Cell);
|
||||
fail("Missing external workbook reference exception expected!");
|
||||
}catch(RuntimeException re) {
|
||||
assertTrue("Unexpected exception: " + re, re.getMessage().indexOf(SOURCE_DUMMY_WORKBOOK_FILENAME) != -1);
|
||||
@ -95,9 +95,9 @@ public class TestMissingWorkbook extends TestCase {
|
||||
FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
|
||||
evaluator.setIgnoreMissingWorkbooks(true);
|
||||
|
||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(lA1Cell));
|
||||
assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(lB1Cell));
|
||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(lC1Cell));
|
||||
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(lA1Cell));
|
||||
assertEquals(CellType.STRING, evaluator.evaluateFormulaCellEnum(lB1Cell));
|
||||
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(lC1Cell));
|
||||
|
||||
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||
assertEquals("POI rocks!", lB1Cell.getStringCellValue());
|
||||
@ -122,9 +122,9 @@ public class TestMissingWorkbook extends TestCase {
|
||||
workbooks.put(SOURCE_DUMMY_WORKBOOK_FILENAME, lSourceEvaluator);
|
||||
lMainWorkbookEvaluator.setupReferencedWorkbooks(workbooks);
|
||||
|
||||
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
|
||||
assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell));
|
||||
assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell));
|
||||
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lA1Cell));
|
||||
assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lB1Cell));
|
||||
assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lC1Cell));
|
||||
|
||||
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
|
||||
assertEquals("Apache rocks!", lB1Cell.getStringCellValue());
|
||||
|
@ -511,7 +511,7 @@ public class TestWorkbookEvaluator {
|
||||
Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
|
||||
|
||||
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
|
||||
CellType resultCellType = eval.evaluateFormulaCell(D1);
|
||||
CellType resultCellType = eval.evaluateFormulaCellEnum(D1);
|
||||
|
||||
// Call should modify the contents, but leave the formula intact
|
||||
assertEquals(CellType.FORMULA, D1.getCellTypeEnum());
|
||||
|
@ -66,11 +66,11 @@ public class TestRandBetween extends TestCase {
|
||||
|
||||
evaluator.clearAllCachedResultValues();
|
||||
formulaCell.setCellFormula("RANDBETWEEN(1,1)");
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(1, formulaCell.getNumericCellValue(), 0);
|
||||
evaluator.clearAllCachedResultValues();
|
||||
formulaCell.setCellFormula("RANDBETWEEN(-1,-1)");
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
||||
|
||||
}
|
||||
@ -86,25 +86,25 @@ public class TestRandBetween extends TestCase {
|
||||
topValueCell.setCellValue(0.1);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(1, formulaCell.getNumericCellValue(), 0);
|
||||
bottomValueCell.setCellValue(-0.1);
|
||||
topValueCell.setCellValue(-0.05);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(0, formulaCell.getNumericCellValue(), 0);
|
||||
bottomValueCell.setCellValue(-1.1);
|
||||
topValueCell.setCellValue(-1.05);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
||||
bottomValueCell.setCellValue(-1.1);
|
||||
topValueCell.setCellValue(-1.1);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ public class TestRandBetween extends TestCase {
|
||||
topValueCell.setCellType(CellType.BLANK);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertTrue(formulaCell.getNumericCellValue() == 0 || formulaCell.getNumericCellValue() == -1);
|
||||
|
||||
}
|
||||
@ -130,7 +130,7 @@ public class TestRandBetween extends TestCase {
|
||||
topValueCell.setCellValue(1);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
|
||||
@ -140,7 +140,7 @@ public class TestRandBetween extends TestCase {
|
||||
topValueCell.setCellValue("STRING");
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
|
||||
@ -149,7 +149,7 @@ public class TestRandBetween extends TestCase {
|
||||
topValueCell.setCellValue("STRING");
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
|
||||
@ -165,14 +165,14 @@ public class TestRandBetween extends TestCase {
|
||||
topValueCell.setCellValue(0);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
bottomValueCell.setCellValue(1);
|
||||
topValueCell.setCellType(CellType.BLANK);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
|
||||
}
|
||||
@ -186,7 +186,7 @@ public class TestRandBetween extends TestCase {
|
||||
topValueCell.setCellValue(Double.MAX_VALUE);
|
||||
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
|
||||
evaluator.clearAllCachedResultValues();
|
||||
evaluator.evaluateFormulaCell(formulaCell);
|
||||
evaluator.evaluateFormulaCellEnum(formulaCell);
|
||||
assertTrue(formulaCell.getNumericCellValue() >= Double.MIN_VALUE && formulaCell.getNumericCellValue() <= Double.MAX_VALUE);
|
||||
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public final class TestIrr extends TestCase {
|
||||
|
||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cell);
|
||||
fe.evaluateFormulaCellEnum(cell);
|
||||
double res = cell.getNumericCellValue();
|
||||
assertEquals(0.143d, Math.round(res * 1000d) / 1000d);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public final class TestMirr extends TestCase {
|
||||
|
||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cell);
|
||||
fe.evaluateFormulaCellEnum(cell);
|
||||
double res = cell.getNumericCellValue();
|
||||
assertEquals(0.18736225093, res, 0.00000001);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public final class TestNper {
|
||||
assertEquals(15.0, cell.getNumericCellValue(), 0.0);
|
||||
|
||||
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
|
||||
fe.evaluateFormulaCell(cell);
|
||||
fe.evaluateFormulaCellEnum(cell);
|
||||
assertEquals(CellType.ERROR, cell.getCachedFormulaResultTypeEnum());
|
||||
assertEquals(FormulaError.NUM.getCode(), cell.getErrorCellValue());
|
||||
wb.close();
|
||||
|
@ -50,7 +50,7 @@ public final class TestNpv extends TestCase {
|
||||
// Enumeration
|
||||
cell.setCellFormula("NPV(A2, A4,A5,A6,A7,A8)+A3");
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cell);
|
||||
fe.evaluateFormulaCellEnum(cell);
|
||||
double res = cell.getNumericCellValue();
|
||||
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");
|
||||
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cell);
|
||||
fe.evaluateFormulaCellEnum(cell);
|
||||
res = cell.getNumericCellValue();
|
||||
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());
|
||||
cellRef = new CellReference(wb.getName("TOTALCOST").getRefersToFormula());
|
||||
HSSFCell tccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell((int)cellRef.getCol());
|
||||
evaluator.evaluateFormulaCell(uccell);
|
||||
evaluator.evaluateFormulaCell(ccell);
|
||||
evaluator.evaluateFormulaCell(tccell);
|
||||
evaluator.evaluateFormulaCellEnum(uccell);
|
||||
evaluator.evaluateFormulaCellEnum(ccell);
|
||||
evaluator.evaluateFormulaCellEnum(tccell);
|
||||
assertEquals(NEW_PART_COST, uccell.getNumericCellValue());
|
||||
assertEquals(NEW_PART_COST*NEW_QUANT, ccell.getNumericCellValue());
|
||||
assertEquals(NEW_PART_COST*NEW_QUANT*MARKUP_COST_2, tccell.getNumericCellValue());
|
||||
|
@ -843,7 +843,7 @@ public abstract class BaseTestBugzillaIssues {
|
||||
|
||||
private Cell evaluateCell(Workbook wb, Cell c) {
|
||||
Sheet s = c.getSheet();
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(c);
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCellEnum(c);
|
||||
return s.getRow(c.getRowIndex()).getCell(c.getColumnIndex());
|
||||
}
|
||||
|
||||
@ -924,8 +924,8 @@ public abstract class BaseTestBugzillaIssues {
|
||||
|
||||
|
||||
// Try to evaluate, with the other file
|
||||
evaluator.evaluateFormulaCell(c1);
|
||||
evaluator.evaluateFormulaCell(c2);
|
||||
evaluator.evaluateFormulaCellEnum(c1);
|
||||
evaluator.evaluateFormulaCellEnum(c2);
|
||||
|
||||
assertEquals(otherCellText, c1.getStringCellValue());
|
||||
assertEquals(otherCellText, c2.getStringCellValue());
|
||||
@ -1132,8 +1132,8 @@ public abstract class BaseTestBugzillaIssues {
|
||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellType());
|
||||
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellType());
|
||||
fe.evaluateFormulaCell(cfn);
|
||||
fe.evaluateFormulaCell(cfs);
|
||||
fe.evaluateFormulaCellEnum(cfn);
|
||||
fe.evaluateFormulaCellEnum(cfs);
|
||||
|
||||
// Now test
|
||||
assertEquals(CellType.NUMERIC, cn.getCellTypeEnum());
|
||||
@ -1261,17 +1261,17 @@ public abstract class BaseTestBugzillaIssues {
|
||||
// Check read ok, and re-evaluate fine
|
||||
cell = row.getCell(5);
|
||||
assertEquals("ab", cell.getStringCellValue());
|
||||
ev.evaluateFormulaCell(cell);
|
||||
ev.evaluateFormulaCellEnum(cell);
|
||||
assertEquals("ab", cell.getStringCellValue());
|
||||
|
||||
cell = row.getCell(6);
|
||||
assertEquals("empty", cell.getStringCellValue());
|
||||
ev.evaluateFormulaCell(cell);
|
||||
ev.evaluateFormulaCellEnum(cell);
|
||||
assertEquals("empty", cell.getStringCellValue());
|
||||
|
||||
cell = row.getCell(7);
|
||||
assertEquals("ab", cell.getStringCellValue());
|
||||
ev.evaluateFormulaCell(cell);
|
||||
ev.evaluateFormulaCellEnum(cell);
|
||||
assertEquals("ab", cell.getStringCellValue());
|
||||
wb2.close();
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ public abstract class BaseTestCell {
|
||||
|
||||
FormulaEvaluator fe = cellA1.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
|
||||
|
||||
fe.evaluateFormulaCell(cellA1);
|
||||
fe.evaluateFormulaCellEnum(cellA1);
|
||||
assertEquals("abc", cellA1.getStringCellValue());
|
||||
|
||||
fe.evaluateInCell(cellA1);
|
||||
@ -523,14 +523,14 @@ public abstract class BaseTestCell {
|
||||
|
||||
cellA1.setCellFormula("\"DEF\"");
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cellA1);
|
||||
fe.evaluateFormulaCellEnum(cellA1);
|
||||
assertEquals("DEF", cellA1.getStringCellValue());
|
||||
cellA1.setCellType(CellType.STRING);
|
||||
assertEquals("DEF", cellA1.getStringCellValue());
|
||||
|
||||
cellA1.setCellFormula("25.061");
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cellA1);
|
||||
fe.evaluateFormulaCellEnum(cellA1);
|
||||
confirmCannotReadString(cellA1);
|
||||
assertEquals(25.061, cellA1.getNumericCellValue(), 0.0);
|
||||
cellA1.setCellType(CellType.STRING);
|
||||
@ -538,7 +538,7 @@ public abstract class BaseTestCell {
|
||||
|
||||
cellA1.setCellFormula("TRUE");
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cellA1);
|
||||
fe.evaluateFormulaCellEnum(cellA1);
|
||||
confirmCannotReadString(cellA1);
|
||||
assertEquals(true, cellA1.getBooleanCellValue());
|
||||
cellA1.setCellType(CellType.STRING);
|
||||
@ -546,7 +546,7 @@ public abstract class BaseTestCell {
|
||||
|
||||
cellA1.setCellFormula("#NAME?");
|
||||
fe.clearAllCachedResultValues();
|
||||
fe.evaluateFormulaCell(cellA1);
|
||||
fe.evaluateFormulaCellEnum(cellA1);
|
||||
confirmCannotReadString(cellA1);
|
||||
assertEquals(FormulaError.NAME, forInt(cellA1.getErrorCellValue()));
|
||||
cellA1.setCellType(CellType.STRING);
|
||||
@ -816,7 +816,7 @@ public abstract class BaseTestCell {
|
||||
Row row = sheet.createRow(0);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellFormula("SQRT(-1)");
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(cell);
|
||||
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCellEnum(cell);
|
||||
assertEquals(36, cell.getErrorCellValue());
|
||||
} finally {
|
||||
wb.close();
|
||||
|
@ -56,8 +56,8 @@ public abstract class BaseTestFormulaEvaluator {
|
||||
|
||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||
|
||||
fe.evaluateFormulaCell(c1);
|
||||
fe.evaluateFormulaCell(c2);
|
||||
fe.evaluateFormulaCellEnum(c1);
|
||||
fe.evaluateFormulaCellEnum(c2);
|
||||
|
||||
assertEquals(6.0, c1.getNumericCellValue(), 0.0001);
|
||||
assertEquals(5.0, c2.getNumericCellValue(), 0.0001);
|
||||
@ -97,10 +97,10 @@ public abstract class BaseTestFormulaEvaluator {
|
||||
// Evaluate and test
|
||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||
|
||||
fe.evaluateFormulaCell(c1);
|
||||
fe.evaluateFormulaCell(c2);
|
||||
fe.evaluateFormulaCell(c3);
|
||||
fe.evaluateFormulaCell(c4);
|
||||
fe.evaluateFormulaCellEnum(c1);
|
||||
fe.evaluateFormulaCellEnum(c2);
|
||||
fe.evaluateFormulaCellEnum(c3);
|
||||
fe.evaluateFormulaCellEnum(c4);
|
||||
|
||||
assertEquals(3.6, c1.getNumericCellValue(), 0.0001);
|
||||
assertEquals(17.5, c2.getNumericCellValue(), 0.0001);
|
||||
@ -289,7 +289,7 @@ public abstract class BaseTestFormulaEvaluator {
|
||||
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
|
||||
|
||||
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
|
||||
fe.evaluateFormulaCell(cellB1);
|
||||
fe.evaluateFormulaCellEnum(cellB1);
|
||||
|
||||
cellA1.setCellValue(2.5);
|
||||
fe.notifyUpdateCell(cellA1);
|
||||
|
@ -345,7 +345,7 @@ public abstract class BaseTestSheetAutosizeColumn {
|
||||
for (Row r : sheet) {
|
||||
for (Cell c : r) {
|
||||
if (c.getCellTypeEnum() == CellType.FORMULA){
|
||||
eval.evaluateFormulaCell(c);
|
||||
eval.evaluateFormulaCellEnum(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user