Search in sources :

Example 16 with OperationEvaluationContext

use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.

the class TestHex2Dec method testEvalOperationEvaluationContextFails.

public void testEvalOperationEvaluationContextFails() {
    OperationEvaluationContext ctx = createContext();
    ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 0) };
    ValueEval result = new Hex2Dec().evaluate(args, ctx);
    assertEquals(ErrorEval.class, result.getClass());
    assertEquals(ErrorEval.VALUE_INVALID, result);
}
Also used : OperationEvaluationContext(org.apache.poi.ss.formula.OperationEvaluationContext) ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 17 with OperationEvaluationContext

use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.

the class TestHex2Dec method createContext.

private OperationEvaluationContext createContext() {
    HSSFWorkbook wb = new HSSFWorkbook();
    wb.createSheet();
    HSSFEvaluationWorkbook workbook = HSSFEvaluationWorkbook.create(wb);
    WorkbookEvaluator workbookEvaluator = new WorkbookEvaluator(workbook, new IStabilityClassifier() {

        @Override
        public boolean isCellFinal(int sheetIndex, int rowIndex, int columnIndex) {
            return true;
        }
    }, null);
    OperationEvaluationContext ctx = new OperationEvaluationContext(workbookEvaluator, workbook, 0, 0, 0, null);
    return ctx;
}
Also used : IStabilityClassifier(org.apache.poi.ss.formula.IStabilityClassifier) WorkbookEvaluator(org.apache.poi.ss.formula.WorkbookEvaluator) OperationEvaluationContext(org.apache.poi.ss.formula.OperationEvaluationContext) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) HSSFEvaluationWorkbook(org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook)

Example 18 with OperationEvaluationContext

use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.

the class TestDec2Hex method testRefs.

public void testRefs() {
    OperationEvaluationContext ctx = createContext();
    ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0) };
    ValueEval result = new Dec2Hex().evaluate(args, -1, -1);
    assertEquals("Had: " + result, StringEval.class, result.getClass());
    assertEquals("7B", ((StringEval) result).getStringValue());
}
Also used : OperationEvaluationContext(org.apache.poi.ss.formula.OperationEvaluationContext) ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 19 with OperationEvaluationContext

use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.

the class TestDec2Hex method testWithTooManyParams.

public void testWithTooManyParams() {
    OperationEvaluationContext ctx = createContext();
    ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0), ctx.getRefEval(0, 1), ctx.getRefEval(0, 1) };
    ValueEval result = new Dec2Hex().evaluate(args, ctx);
    assertEquals(ErrorEval.class, result.getClass());
    assertEquals(ErrorEval.VALUE_INVALID, result);
}
Also used : OperationEvaluationContext(org.apache.poi.ss.formula.OperationEvaluationContext) ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Example 20 with OperationEvaluationContext

use of org.apache.poi.ss.formula.OperationEvaluationContext in project poi by apache.

the class TestHex2Dec method testRefs.

public void testRefs() {
    OperationEvaluationContext ctx = createContext();
    ValueEval[] args = new ValueEval[] { ctx.getRefEval(0, 0) };
    ValueEval result = new Hex2Dec().evaluate(args, -1, -1);
    assertEquals(NumberEval.class, result.getClass());
    assertEquals("0", ((NumberEval) result).getStringValue());
}
Also used : OperationEvaluationContext(org.apache.poi.ss.formula.OperationEvaluationContext) ValueEval(org.apache.poi.ss.formula.eval.ValueEval)

Aggregations

OperationEvaluationContext (org.apache.poi.ss.formula.OperationEvaluationContext)32 ValueEval (org.apache.poi.ss.formula.eval.ValueEval)27 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)5 HSSFEvaluationWorkbook (org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook)4 IStabilityClassifier (org.apache.poi.ss.formula.IStabilityClassifier)4 WorkbookEvaluator (org.apache.poi.ss.formula.WorkbookEvaluator)4 Cell (org.apache.poi.ss.usermodel.Cell)2 Row (org.apache.poi.ss.usermodel.Row)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 TestHSSFWorkbook (org.apache.poi.hssf.usermodel.TestHSSFWorkbook)1 NumberEval (org.apache.poi.ss.formula.eval.NumberEval)1 FreeRefFunction (org.apache.poi.ss.formula.functions.FreeRefFunction)1 AggregatingUDFFinder (org.apache.poi.ss.formula.udf.AggregatingUDFFinder)1 DefaultUDFFinder (org.apache.poi.ss.formula.udf.DefaultUDFFinder)1 UDFFinder (org.apache.poi.ss.formula.udf.UDFFinder)1 Test (org.junit.Test)1