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

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


    if(ve instanceof BlankEval || ve == null) {
      // TODO - shouldn't BlankEval.INSTANCE be used always instead of null?
      // null seems to occur when the blank cell is part of an area ref (but not reliably)
      if(isScalarProduct) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      return 0;
    }

    if(ve instanceof ErrorEval) {
      throw new EvaluationException((ErrorEval)ve);
    }
    if(ve instanceof StringEval) {
      if(isScalarProduct) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      // Note for area SUMPRODUCTs, string values are interpreted as zero
      // even if they would parse as valid numeric values
      return 0;
    }
View Full Code Here


      LinearOffsetRange orRow, LinearOffsetRange orCol) throws EvaluationException {
    LinearOffsetRange absRows = orRow.normaliseAndTranslate(baseRef.getFirstRowIndex());
    LinearOffsetRange absCols = orCol.normaliseAndTranslate(baseRef.getFirstColumnIndex());

    if(absRows.isOutOfBounds(0, LAST_VALID_ROW_INDEX)) {
      throw new EvaluationException(ErrorEval.REF_INVALID);
    }
    if(absCols.isOutOfBounds(0, LAST_VALID_COLUMN_INDEX)) {
      throw new EvaluationException(ErrorEval.REF_INVALID);
    }
    return baseRef.offset(orRow.getFirstIndex(), orRow.getLastIndex(), orCol.getFirstIndex(), orCol.getLastIndex());
  }
View Full Code Here

    }
    if(eval instanceof AreaEval) {
      return new BaseRef((AreaEval)eval);
    }
    if (eval instanceof ErrorEval) {
      throw new EvaluationException((ErrorEval) eval);
    }
    throw new EvaluationException(ErrorEval.VALUE_INVALID);
  }
View Full Code Here

    }
    if (ve instanceof StringEval) {
      StringEval se = (StringEval) ve;
      Double d = OperandResolver.parseDouble(se.getStringValue());
      if(d == null) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      return d.doubleValue();
    }
    if (ve instanceof BoolEval) {
      // in the context of OFFSET, booleans resolve to 0 and 1.
View Full Code Here

      } else {
        // all other combinations of value types are silently ignored
      }
    }
    if (firstXerr != null) {
      throw new EvaluationException(firstXerr);
    }
    if (firstYerr != null) {
      throw new EvaluationException(firstYerr);
    }
    if (!accumlatedSome) {
      throw new EvaluationException(ErrorEval.DIV_ZERO);
    }
    return result;
  }
View Full Code Here

    return result;
  }

  private static ValueVector createValueVector(ValueEval arg) throws EvaluationException {
    if (arg instanceof ErrorEval) {
      throw new EvaluationException((ErrorEval) arg);
    }
    if (arg instanceof AreaEval) {
      return new AreaValueArray((AreaEval) arg);
    }
    if (arg instanceof RefEval) {
View Full Code Here

      return ((AreaEval) eval).offset(0, aeRange.getHeight()-1, 0, aeRange.getWidth()-1);
    }
    if (eval instanceof RefEval) {
      return ((RefEval)eval).offset(0, aeRange.getHeight()-1, 0, aeRange.getWidth()-1);
    }
    throw new EvaluationException(ErrorEval.VALUE_INVALID);
  }
View Full Code Here

      return (AreaEval) eval;
    }
    if (eval instanceof RefEval) {
      return ((RefEval)eval).offset(0, 0, 0, 0);
    }
    throw new EvaluationException(ErrorEval.VALUE_INVALID);
  }
View Full Code Here

  public static double calculate(double pStartDateVal, double pEndDateVal, int basis) throws EvaluationException {

    if (basis < 0 || basis >= 5) {
      // if basis is invalid the result is #NUM!
      throw new EvaluationException(ErrorEval.NUM_ERROR);
    }

    // common logic for all bases

    // truncate day values
View Full Code Here

  }

  private static Calendar parseDate(String strVal) throws EvaluationException {
    String[] parts = Pattern.compile("/").split(strVal);
    if (parts.length != 3) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    String part2 = parts[2];
    int spacePos = part2.indexOf(' ');
    if (spacePos > 0) {
      // drop time portion if present
      part2 = part2.substring(0, spacePos);
    }
    int f0;
    int f1;
    int f2;
    try {
      f0 = Integer.parseInt(parts[0]);
      f1 = Integer.parseInt(parts[1]);
      f2 = Integer.parseInt(part2);
    } catch (NumberFormatException e) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    if (f0<0 || f1<0 || f2<0 || (f0>12 && f1>12 && f2>12)) {
      // easy to see this cannot be a valid date
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }

    if (f0 >= 1900 && f0 < 9999) {
      // when 4 digit value appears first, the format is YYYY/MM/DD, regardless of OS settings
      return makeDate(f0, f1, f2);
View Full Code Here

TOP

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

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.