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

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


    int cellType = cell.getCellType();
    switch (cellType) {
      case Cell.CELL_TYPE_NUMERIC:
        return new NumberEval(cell.getNumericCellValue());
      case Cell.CELL_TYPE_STRING:
        return new StringEval(cell.getStringCellValue());
      case Cell.CELL_TYPE_BOOLEAN:
        return BoolEval.valueOf(cell.getBooleanCellValue());
      case Cell.CELL_TYPE_BLANK:
        return BlankEval.instance;
      case Cell.CELL_TYPE_ERROR:
View Full Code Here


    }
    if (ptg instanceof NumberPtg) {
      return new NumberEval(((NumberPtg)ptg).getValue());
    }
    if (ptg instanceof StringPtg) {
      return new StringEval(((StringPtg) ptg).getValue());
    }
    if (ptg instanceof BoolPtg) {
      return BoolEval.valueOf(((BoolPtg) ptg).getValue());
    }
    if (ptg instanceof ErrPtg) {
View Full Code Here

          default:
            // never matches (also inconsistent with above three cases).
            // for example '>5' does not match '6',
            return false;
        }
        StringEval se = (StringEval)x;
        Double val = OperandResolver.parseDouble(se.getStringValue());
        if(val == null) {
          // x is text that is not a number
          return false;
        }
        return _value == val.doubleValue();
View Full Code Here

        if (true) { // change to false to observe more intuitive behaviour
          // Note - Unlike with numbers, it seems that COUNTIF never matches
          // boolean values when the target(x) is a string
          return false;
        }
        StringEval se = (StringEval)x;
        Boolean val = parseBoolean(se.getStringValue());
        if(val == null) {
          // x is text that is not a boolean
          return false;
        }
        testValue = boolToInt(val.booleanValue());
View Full Code Here

          default:
            // never matches (also inconsistent with above three cases).
            // for example '>5' does not match '6',
            return false;
        }
        StringEval se = (StringEval)x;
        Double val = OperandResolver.parseDouble(se.getStringValue());
        if(val == null) {
          // x is text that is not a number
          return false;
        }
        return _value == val.doubleValue();
View Full Code Here

        if (true) { // change to false to observe more intuitive behaviour
          // Note - Unlike with numbers, it seems that COUNTIF never matches
          // boolean values when the target(x) is a string
          return false;
        }
        StringEval se = (StringEval)x;
        Boolean val = parseBoolean(se.getStringValue());
        if(val == null) {
          // x is text that is not a boolean
          return false;
        }
        testValue = boolToInt(val.booleanValue());
View Full Code Here

    if (eval instanceof BoolEval) {
      BoolEval be = (BoolEval) eval;
      return CellValue.valueOf(be.getBooleanValue());
    }
    if (eval instanceof StringEval) {
      StringEval ne = (StringEval) eval;
      return new CellValue(ne.getStringValue());
    }
    if (eval instanceof ErrorEval) {
      return CellValue.getError(((ErrorEval)eval).getErrorCode());
    }
    throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
View Full Code Here

    // Error handling for lookup_range arg is also unusual
    if(eval instanceof NumericValueEval) {
      throw new EvaluationException(ErrorEval.NA);
    }
    if (eval instanceof StringEval) {
      StringEval se = (StringEval) eval;
      Double d = OperandResolver.parseDouble(se.getStringValue());
      if(d == null) {
        // plain string
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      // else looks like a number
View Full Code Here

    if(match_type instanceof NumericValueEval) {
      NumericValueEval ne = (NumericValueEval) match_type;
      return ne.getNumberValue();
    }
    if (match_type instanceof StringEval) {
      StringEval se = (StringEval) match_type;
      Double d = OperandResolver.parseDouble(se.getStringValue());
      if(d == null) {
        // plain string
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      // if the string parses as a number, it is OK
View Full Code Here

      // All errors get translated to #REF!
      throw EvaluationException.invalidRef();
    }
    int oneBasedIndex;
    if(veRowColIndexArg instanceof StringEval) {
      StringEval se = (StringEval) veRowColIndexArg;
      String strVal = se.getStringValue();
      Double dVal = OperandResolver.parseDouble(strVal);
      if(dVal == null) {
        // String does not resolve to a number. Raise #REF! error.
        throw EvaluationException.invalidRef();
        // This includes text booleans "TRUE" and "FALSE".  They are not valid.
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.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.