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

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


    confirmCountA(1, args);
   
    args = new Eval[] {
      new NumberEval(0)
      new NumberEval(0),
      new StringEval(""),
    };
    confirmCountA(3, args);
   
    args = new Eval[] {
      EvalFactory.createAreaEval("D2:F5", 3, 4)
View Full Code Here


    ValueEval[] values;
   
    // when criteria is a boolean value
    values = new ValueEval[] {
        new NumberEval(0)
        new StringEval("TRUE")// note - does not match boolean TRUE
        BoolEval.TRUE,
        BoolEval.FALSE,
        BoolEval.TRUE,
        BlankEval.INSTANCE,
    };
    range = createAreaEval("A1:B2", values);
    confirmCountIf(2, range, BoolEval.TRUE);
   
    // when criteria is numeric
    values = new ValueEval[] {
        new NumberEval(0)
        new StringEval("2")
        new StringEval("2.001")
        new NumberEval(2)
        new NumberEval(2)
        BoolEval.TRUE,
        BlankEval.INSTANCE,
    };
    range = createAreaEval("A1:B2", values);
    confirmCountIf(3, range, new NumberEval(2));
    // note - same results when criteria is a string that parses as the number with the same value
    confirmCountIf(3, range, new StringEval("2.00"));
   
    if (false) { // not supported yet:
      // when criteria is an expression (starting with a comparison operator)
      confirmCountIf(4, range, new StringEval(">1"));
    }
  }
View Full Code Here

    assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
  }
 
  public void testBasic() {
   
    confirmMid(new StringEval("galactic"), new NumberEval(3), new NumberEval(4), "lact");
  }
View Full Code Here

  /**
   * Valid cases where args are not precisely (string, int, int) but can be resolved OK.
   */
  public void testUnusualArgs() {
    // startPos with fractional digits
    confirmMid(new StringEval("galactic"), new NumberEval(3.1), new NumberEval(4), "lact");
   
    // string startPos
    confirmMid(new StringEval("galactic"), new StringEval("3"), new NumberEval(4), "lact");
   
    // 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 = new Area2DEval(new AreaPtg("A1:A1"), new ValueEval[] { new NumberEval(2), } );
    RefEval reNumChars = new Ref2DEval(new ReferencePtg("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, "");
    confirmMid(new StringEval("galactic"), new NumberEval(3), BoolEval.TRUE, "l");
    confirmMid(BlankEval.INSTANCE, new NumberEval(3), BoolEval.TRUE, "");
 
  }
View Full Code Here

  /**
   * Extreme values for startPos and numChars
   */
  public void testExtremes() {
    confirmMid(new StringEval("galactic"), new NumberEval(4), new NumberEval(400), "actic");
   
    confirmMid(new StringEval("galactic"), new NumberEval(30), new NumberEval(4), "");
    confirmMid(new StringEval("galactic"), new NumberEval(3), new NumberEval(0), "");
  }
View Full Code Here

  /**
   * All sorts of ways to make MID return defined errors.
   */
  public void testErrors() {
    confirmMid(ErrorEval.NAME_INVALID, new NumberEval(3), new NumberEval(4), ErrorEval.NAME_INVALID);
    confirmMid(new StringEval("galactic"), ErrorEval.NAME_INVALID, new NumberEval(4), ErrorEval.NAME_INVALID);
    confirmMid(new StringEval("galactic"), new NumberEval(3), ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
    confirmMid(new StringEval("galactic"), ErrorEval.DIV_ZERO, ErrorEval.NAME_INVALID, ErrorEval.DIV_ZERO);
   
    confirmMid(new StringEval("galactic"), BlankEval.INSTANCE, new NumberEval(3.1), ErrorEval.VALUE_INVALID);
   
    confirmMid(new StringEval("galactic"), new NumberEval(0), new NumberEval(4), ErrorEval.VALUE_INVALID);
    confirmMid(new StringEval("galactic"), new NumberEval(1), new NumberEval(-1), ErrorEval.VALUE_INVALID);
  }
View Full Code Here

    Eval arg = new Ref2DEval(new ReferencePtg((short)1, (short)1, false, false), innerValue);
    return invokeT(arg);
  }
 
  private static void confirmText(String text) {
    Eval arg = new StringEval(text);
    Eval eval = invokeT(arg);
    StringEval se = (StringEval) eval;
    assertEquals(text, se.getStringValue());
  }
View Full Code Here

  }

  public void testRefValues() {
    Eval eval;
   
    eval = invokeTWithReference(new StringEval("def"));
    confirmString(eval, "def");
    eval = invokeTWithReference(new StringEval(" "));
    confirmString(eval, " ");

    eval = invokeTWithReference(new NumberEval(2));
    confirmString(eval, "");
    eval = invokeTWithReference(BoolEval.TRUE);
View Full Code Here

    assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
  }
 
  public void testBasic() {
   
    confirmTrim(new StringEval(" hi "), "hi");
    confirmTrim(new StringEval("hi "), "hi");
    confirmTrim(new StringEval("  hi"), "hi");
    confirmTrim(new StringEval(" hi there  "), "hi there");
    confirmTrim(new StringEval(""), "");
    confirmTrim(new StringEval("   "), "");
  }
View Full Code Here

    assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
  }
 
  public void testBasic() {
   
    confirmLen(new StringEval("galactic"), 8);
  }
View Full Code Here

TOP

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

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.