use of org.apache.poi.ss.formula.eval.RefEval in project poi by apache.
the class T method evaluate.
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0) {
ValueEval arg = arg0;
if (arg instanceof RefEval) {
// always use the first sheet
RefEval re = (RefEval) arg;
arg = re.getInnerValueEval(re.getFirstSheetIndex());
} else if (arg instanceof AreaEval) {
// when the arg is an area, choose the top left cell
arg = ((AreaEval) arg).getRelativeValue(0, 0);
}
if (arg instanceof StringEval) {
// Text values are returned unmodified
return arg;
}
if (arg instanceof ErrorEval) {
// Error values also returned unmodified
return arg;
}
// for all other argument types the result is empty string
return StringEval.EMPTY_INSTANCE;
}
use of org.apache.poi.ss.formula.eval.RefEval in project poi by apache.
the class Sumproduct method getScalarValue.
private static double getScalarValue(ValueEval arg) throws EvaluationException {
ValueEval eval;
if (arg instanceof RefEval) {
RefEval re = (RefEval) arg;
if (re.getNumberOfSheets() > 1) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
eval = re.getInnerValueEval(re.getFirstSheetIndex());
} else {
eval = arg;
}
if (eval == null) {
throw new RuntimeException("parameter may not be null");
}
if (eval instanceof AreaEval) {
AreaEval ae = (AreaEval) eval;
// an area ref can work as a scalar value if it is 1x1
if (!ae.isColumn() || !ae.isRow()) {
throw new EvaluationException(ErrorEval.VALUE_INVALID);
}
eval = ae.getRelativeValue(0, 0);
}
return getProductTerm(eval, true);
}
Aggregations