public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { throw new NotImplementedFunctionException(_functionName); } }
public FormulaEvaluationProblems getEvaluationProblems(Sheet sheet) { Set<String> unsupportedFunctions = new HashSet<>(); Map<CellReference,Exception> unevaluatableCells = new HashMap<>(); for (Row r : sheet) { for (Cell c : r) { try { evaluator.evaluate(c); } catch (Exception e) { if (e instanceof NotImplementedException && e.getCause() != null) { // Has been wrapped with cell details, but we know those e = (Exception)e.getCause(); } if (e instanceof NotImplementedFunctionException) { NotImplementedFunctionException nie = (NotImplementedFunctionException)e; unsupportedFunctions.add(nie.getFunctionName()); } unevaluatableCells.put(new CellReference(c), e); } } } return new FormulaEvaluationProblems(unsupportedFunctions, unevaluatableCells); }
public ValueEval evaluate(ValueEval[] operands, int srcRow, int srcCol) { throw new NotImplementedFunctionException(_functionName); } public String getFunctionName() {
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { int nIncomingArgs = args.length; if(nIncomingArgs < 1) { throw new RuntimeException("function name argument missing"); } ValueEval nameArg = args[0]; String functionName; if (nameArg instanceof FunctionNameEval) { functionName = ((FunctionNameEval) nameArg).getFunctionName(); } else { throw new RuntimeException("First argument should be a NameEval, but got (" + nameArg.getClass().getName() + ")"); } FreeRefFunction targetFunc = ec.findUserDefinedFunction(functionName); if (targetFunc == null) { throw new NotImplementedFunctionException(functionName); } int nOutGoingArgs = nIncomingArgs -1; ValueEval[] outGoingArgs = new ValueEval[nOutGoingArgs]; System.arraycopy(args, 1, outGoingArgs, 0, nOutGoingArgs); return targetFunc.evaluate(outGoingArgs, ec); } }
private static Function findFunction(int functionCode) throws EvaluationException { switch (functionCode) { case 1: return subtotalInstance(AggregateFunction.AVERAGE); case 2: return Count.subtotalInstance(); case 3: return Counta.subtotalInstance(); case 4: return subtotalInstance(AggregateFunction.MAX); case 5: return subtotalInstance(AggregateFunction.MIN); case 6: return subtotalInstance(AggregateFunction.PRODUCT); case 7: return subtotalInstance(AggregateFunction.STDEV); case 8: throw new NotImplementedFunctionException("STDEVP"); case 9: return subtotalInstance(AggregateFunction.SUM); case 10: throw new NotImplementedFunctionException("VAR"); case 11: throw new NotImplementedFunctionException("VARP"); } if (functionCode > 100 && functionCode < 112) { throw new NotImplementedException("SUBTOTAL - with 'exclude hidden values' option"); } throw EvaluationException.invalidValue(); }
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { throw new NotImplementedFunctionException(_functionName); } }
public ValueEval evaluate(ValueEval[] operands, int srcRow, int srcCol) { throw new NotImplementedFunctionException(_functionName); } public String getFunctionName() {
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) { int nIncomingArgs = args.length; if(nIncomingArgs < 1) { throw new RuntimeException("function name argument missing"); } ValueEval nameArg = args[0]; String functionName; if (nameArg instanceof FunctionNameEval) { functionName = ((FunctionNameEval) nameArg).getFunctionName(); } else { throw new RuntimeException("First argument should be a NameEval, but got (" + nameArg.getClass().getName() + ")"); } FreeRefFunction targetFunc = ec.findUserDefinedFunction(functionName); if (targetFunc == null) { throw new NotImplementedFunctionException(functionName); } int nOutGoingArgs = nIncomingArgs -1; ValueEval[] outGoingArgs = new ValueEval[nOutGoingArgs]; System.arraycopy(args, 1, outGoingArgs, 0, nOutGoingArgs); return targetFunc.evaluate(outGoingArgs, ec); } }
private static Function findFunction(int functionCode) throws EvaluationException { switch (functionCode) { case 1: return subtotalInstance(AggregateFunction.AVERAGE); case 2: return Count.subtotalInstance(); case 3: return Counta.subtotalInstance(); case 4: return subtotalInstance(AggregateFunction.MAX); case 5: return subtotalInstance(AggregateFunction.MIN); case 6: return subtotalInstance(AggregateFunction.PRODUCT); case 7: return subtotalInstance(AggregateFunction.STDEV); case 8: throw new NotImplementedFunctionException("STDEVP"); case 9: return subtotalInstance(AggregateFunction.SUM); case 10: throw new NotImplementedFunctionException("VAR"); case 11: throw new NotImplementedFunctionException("VARP"); } if (functionCode > 100 && functionCode < 112) { throw new NotImplementedException("SUBTOTAL - with 'exclude hidden values' option"); } throw EvaluationException.invalidValue(); }