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

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


      } 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

  }

  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

  /**
   * @param month 1-based
   */
  private static Calendar makeDate(int year, int month, int day) throws EvaluationException {
    if (month < 1 || month > 12) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    Calendar cal = new GregorianCalendar(year, month-1, 1, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    if (day <1 || day>cal.getActualMaximum(Calendar.DAY_OF_MONTH)) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    cal.set(Calendar.DAY_OF_MONTH, day);
    return cal;
  }
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(Eval 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

    }
    if (eval instanceof AreaEval) {
      AreaEval ae = (AreaEval) eval;
      // an area ref can work as a scalar value if it is 1x1
      if(!ae.isColumn() || !ae.isRow()) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      eval = ae.getRelativeValue(0, 0);
    }

    if (!(eval instanceof ValueEval)) {
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.