Package org.apache.poi.hssf.record.formula.eval

Examples of org.apache.poi.hssf.record.formula.eval.RefEval


    assertEquals(expected, nve.getNumberValue(), 0);
  }

  public void testScalarSimple() {

    RefEval refEval = EvalFactory.createRefEval("A1", new NumberEval(3));
    Eval[] args = {
      refEval,
      new NumberEval(2),
    };
    Eval result = invokeSumproduct(args);
View Full Code Here


   * @return a <tt>NumberEval</tt>, <tt>StringEval</tt>, <tt>BoolEval</tt>,
   *  <tt>BlankEval</tt> or <tt>ErrorEval</tt>. Never <code>null</code>.
   */
  private static ValueEval dereferenceValue(ValueEval evaluationResult, int srcRowNum, int srcColNum) {
    if (evaluationResult instanceof RefEval) {
      RefEval rv = (RefEval) evaluationResult;
      return rv.getInnerValueEval();
    }
    if (evaluationResult instanceof AreaEval) {
      AreaEval ae = (AreaEval) evaluationResult;
      if (ae.isRow()) {
        if(ae.isColumn()) {
View Full Code Here

    Eval criteriaArg = args[1];
    if(criteriaArg instanceof RefEval) {
      // criteria is not a literal value, but a cell reference
      // for example COUNTIF(B2:D4, E1)
      RefEval re = (RefEval)criteriaArg;
      criteriaArg = re.getInnerValueEval();
    } else {
      // other non literal tokens such as function calls, have been fully evaluated
      // for example COUNTIF(B2:D4, COLUMN(E1))
    }
    if(criteriaArg instanceof BlankEval) {
View Full Code Here

    // text (first) arg type is number, other args are strings with fractional digits
    confirmMid(new NumberEval(123456), new StringEval("3.1"), new StringEval("2.9"), "34");

    // startPos is 1x1 area ref, numChars is cell ref
    AreaEval aeStart = EvalFactory.createAreaEval("A1:A1", new ValueEval[] { new NumberEval(2), } );
    RefEval reNumChars = EvalFactory.createRefEval("B1", new NumberEval(3));
    confirmMid(new StringEval("galactic"), aeStart, reNumChars, "ala");

    confirmMid(new StringEval("galactic"), new NumberEval(3.1), BlankEval.INSTANCE, "");

    confirmMid(new StringEval("galactic"), new NumberEval(3), BoolEval.FALSE, "");
View Full Code Here

        }
      }
      return;
    }
    if (arg instanceof RefEval) {
      RefEval re = (RefEval) arg;
      collectValue(re.getInnerValueEval(), temp, true);
      return;
    }
    collectValue(arg, temp, true);

  }
View Full Code Here

    if (eval instanceof AreaEval) {
      return (AreaEval) eval;
    }

    if(eval instanceof RefEval) {
      RefEval refEval = (RefEval) eval;
      // Make this cell ref look like a 1x1 area ref.

      // It doesn't matter if eval is a 2D or 3D ref, because that detail is never asked of AreaEval.
      return refEval.offset(0, 0, 0, 0);
    }
    throw EvaluationException.invalidValue();
  }
View Full Code Here

  private static double getScalarValue(Eval arg) throws EvaluationException {
   
    Eval eval;
    if (arg instanceof RefEval) {
      RefEval re = (RefEval) arg;
      eval = re.getInnerValueEval();
    } else {
      eval = arg;
    }
   
    if (eval == null) {
View Full Code Here

        }
      }
      return;
    }
    if (operand instanceof RefEval) {
      RefEval re = (RefEval) operand;
      collectValue(re.getInnerValueEval(), true, temp);
      return;
    }
    collectValue((ValueEval)operand, false, temp);
  }
View Full Code Here

    }
  }

  private static ValueVector evaluateLookupRange(Eval eval) throws EvaluationException {
    if (eval instanceof RefEval) {
      RefEval re = (RefEval) eval;
      return new SingleValueVector(re.getInnerValueEval());
    }
    if (eval instanceof AreaEval) {
      ValueVector result = LookupUtils.createVector((AreaEval)eval);
      if (result == null) {
        throw new EvaluationException(ErrorEval.NA);
View Full Code Here

    // text (first) arg type is number, other args are strings with fractional digits
    confirmMid(new NumberEval(123456), new StringEval("3.1"), new StringEval("2.9"), "34");

    // startPos is 1x1 area ref, numChars is cell ref
    AreaEval aeStart = EvalFactory.createAreaEval("A1:A1", new ValueEval[] { new NumberEval(2), } );
    RefEval reNumChars = EvalFactory.createRefEval("B1", new NumberEval(3));
    confirmMid(new StringEval("galactic"), aeStart, reNumChars, "ala");

    confirmMid(new StringEval("galactic"), new NumberEval(3.1), BlankEval.instance, "");

    confirmMid(new StringEval("galactic"), new NumberEval(3), BoolEval.FALSE, "");
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.formula.eval.RefEval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.