Package org.apache.poi.ss.formula.eval

Examples of org.apache.poi.ss.formula.eval.AreaEval


    ValueEval[] values = {
        new NumberEval(25.0),
        new NumberEval(26.0),
        new NumberEval(28.0),
    };
    AreaEval arg0 = EvalFactory.createAreaEval("A10:C10", values);
    ValueEval[] args = new ValueEval[] { arg0, MissingArgEval.instance, new NumberEval(2), };
    ValueEval actualResult;
    try {
      actualResult = FUNC_INST.evaluate(args, -1, -1);
    } catch (RuntimeException e) {
      if (e.getMessage().equals("Unexpected arg eval type (org.apache.poi.hssf.record.formula.eval.MissingArgEval")) {
        throw new AssertionFailedError("Identified bug 47048b - INDEX() should support missing-arg");
      }
      throw e;
    }
    // result should be an area eval "B10:B10"
    AreaEval ae = confirmAreaEval("B10:B10", actualResult);
    actualResult = ae.getValue(0, 0);
    assertEquals(NumberEval.class, actualResult.getClass());
    assertEquals(26.0, ((NumberEval)actualResult).getNumberValue(), 0.0);
  }
View Full Code Here


   * This works because the INDEX() function returns a reference to A2 (not the value of A2)
   */
  public void testReferenceResult() {
    ValueEval[] values = new ValueEval[4];
    Arrays.fill(values, NumberEval.ZERO);
    AreaEval arg0 = EvalFactory.createAreaEval("A1:B2", values);
    ValueEval[] args = new ValueEval[] { arg0, new NumberEval(2), new NumberEval(1), };
    ValueEval ve = FUNC_INST.evaluate(args, -1, -1);
    confirmAreaEval("A2:A2", ve);
  }
View Full Code Here

   * @return <tt>ve</tt> cast to {@link AreaEval} if it is valid
   */
  private static AreaEval confirmAreaEval(String refText, ValueEval ve) {
    CellRangeAddress cra = CellRangeAddress.valueOf(refText);
    assertTrue(ve instanceof AreaEval);
    AreaEval ae = (AreaEval) ve;
    assertEquals(cra.getFirstRow(), ae.getFirstRow());
    assertEquals(cra.getFirstColumn(), ae.getFirstColumn());
    assertEquals(cra.getLastRow(), ae.getLastRow());
    assertEquals(cra.getLastColumn(), ae.getLastColumn());
    return ae;
  }
View Full Code Here

  private static final String NULL = null;

  public void testCountBlank() {

    AreaEval range;
    ValueEval[] values;

    values = new ValueEval[] {
        new NumberEval(0),
        new StringEval("")// note - does not match blank
View Full Code Here

    confirmCountA(59, args);
  }

  public void testCountIf() {

    AreaEval range;
    ValueEval[] values;

    // when criteria is a boolean value
    values = new ValueEval[] {
        new NumberEval(0),
View Full Code Here

    }
    assertFalse(mp.matches(seA));
    assertTrue(mp.matches(seB));

    // general tests for not-equal (<>) operator
    AreaEval range;
    ValueEval[] values;

    values = new ValueEval[] {
        new StringEval("aa"),
        new StringEval("def"),
View Full Code Here

    /**
     * String criteria in COUNTIF are case insensitive;
     * for example, the string "apples" and the string "APPLES" will match the same cells.
     */
    public void testCaseInsensitiveStringComparison() {
        AreaEval range;
        ValueEval[] values;

        values = new ValueEval[] {
                new StringEval("no"),
                new StringEval("NO"),
View Full Code Here

        new NumberEval(21),
        new NumberEval(25),
        new NumberEval(25),
        new NumberEval(25),
    };
    AreaEval arg0 = EvalFactory.createAreaEval("C1:C6", values);

    ValueEval criteriaArg = EvalFactory.createRefEval("A1", new NumberEval(25));
    ValueEval[] args=  { arg0, criteriaArg, };

    double actual = NumericFunctionInvoker.invoke(new Countif(), args);
View Full Code Here

    ValueEval v0 = new NumberEval(2.0);
    ValueEval v1 = new StringEval("abc");
    ValueEval v2 = ErrorEval.DIV_ZERO;

    AreaEval ev = EvalFactory.createAreaEval("A10:A12", new ValueEval[] { v0, v1, v2, });

    I_MatchPredicate mp;
    mp = Countif.createCriteriaPredicate(ev, 9, srcColIx);
    confirmPredicate(true, mp, srcColIx);
    confirmPredicate(false, mp, "abc");
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, "");
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.eval.AreaEval

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.