use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestSumproduct method testMismatchAreaDimensions.
public void testMismatchAreaDimensions() {
AreaEval aeA = EvalFactory.createAreaEval("A1:A3", new ValueEval[3]);
AreaEval aeB = EvalFactory.createAreaEval("B1:D1", new ValueEval[3]);
ValueEval[] args;
args = new ValueEval[] { aeA, aeB };
assertEquals(ErrorEval.VALUE_INVALID, invokeSumproduct(args));
args = new ValueEval[] { aeA, new NumberEval(5) };
assertEquals(ErrorEval.VALUE_INVALID, invokeSumproduct(args));
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestSumproduct method testScalarSimple.
public void testScalarSimple() {
RefEval refEval = EvalFactory.createRefEval("A1", new NumberEval(3));
ValueEval[] args = { refEval, new NumberEval(2) };
ValueEval result = invokeSumproduct(args);
confirmDouble(6D, result);
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestSumproduct method testAreaSimple.
public void testAreaSimple() {
ValueEval[] aValues = { new NumberEval(2), new NumberEval(4), new NumberEval(5) };
ValueEval[] bValues = { new NumberEval(3), new NumberEval(6), new NumberEval(7) };
AreaEval aeA = EvalFactory.createAreaEval("A1:A3", aValues);
AreaEval aeB = EvalFactory.createAreaEval("B1:B3", bValues);
ValueEval[] args = { aeA, aeB };
ValueEval result = invokeSumproduct(args);
confirmDouble(65D, result);
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestText method testTextWithDeciamlFormatSecondArg.
@Test
public void testTextWithDeciamlFormatSecondArg() {
ValueEval numArg = new NumberEval(321321.321);
ValueEval formatArg = new StringEval("#,###.00000");
ValueEval[] args = { numArg, formatArg };
ValueEval result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(LocaleUtil.getUserLocale());
char groupSeparator = dfs.getGroupingSeparator();
char decimalSeparator = dfs.getDecimalSeparator();
ValueEval testResult = new StringEval("321" + groupSeparator + "321" + decimalSeparator + "32100");
assertEquals(testResult.toString(), result.toString());
numArg = new NumberEval(321.321);
formatArg = new StringEval("00000.00000");
args[0] = numArg;
args[1] = formatArg;
result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
testResult = new StringEval("00321" + decimalSeparator + "32100");
assertEquals(testResult.toString(), result.toString());
formatArg = new StringEval("$#.#");
args[1] = formatArg;
result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
testResult = new StringEval("$321" + decimalSeparator + "3");
assertEquals(testResult.toString(), result.toString());
}
use of org.apache.poi.ss.formula.eval.ValueEval in project poi by apache.
the class TestText method testTextWithStringFirstArg.
@Test
public void testTextWithStringFirstArg() {
ValueEval strArg = new StringEval("abc");
ValueEval formatArg = new StringEval("abc");
ValueEval[] args = { strArg, formatArg };
ValueEval result = TextFunction.TEXT.evaluate(args, -1, (short) -1);
assertEquals(ErrorEval.VALUE_INVALID, result);
}
Aggregations