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

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


      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

     *
     * @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
     */
     private void checkValue(double result) throws EvaluationException {
         if (Double.isNaN(result) || Double.isInfinite(result)) {
             throw new EvaluationException(ErrorEval.NUM_ERROR);
         }
     }   
View Full Code Here

        atleastOneNonBlank = true;
      }
    }

    if (!atleastOneNonBlank) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    return result;
  }
View Full Code Here

  }

  private static double evaluate(int year, int month, int pDay) throws EvaluationException {

    if (year < 0 || month < 0 || pDay < 0) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }

    if (year == 1900 && month == Calendar.FEBRUARY && pDay == 29) {
      return 60.0;
    }
View Full Code Here

      NumberEval ne = (NumberEval) ve;
      temp.add(ne.getNumberValue());
      return;
    }
    if (ve instanceof ErrorEval) {
      throw new EvaluationException((ErrorEval) ve);
    }
    if (ve instanceof StringEval) {
      if (isViaReference) {
        // ignore all ref strings
        return;
      }
      String s = ((StringEval) ve).getStringValue();
      Double d = OperandResolver.parseDouble(s);
      if(d == null) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      temp.add(d.doubleValue());
      return;
    }
    if (ve instanceof BoolEval) {
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

    double result;
    try {
      ValueEval ve = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
      result = OperandResolver.coerceValueToDouble(ve);
      if (Double.isNaN(result) || Double.isInfinite(result)) {
        throw new EvaluationException(ErrorEval.NUM_ERROR);
      }
      aeRange = convertRangeArg(arg1);
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
View Full Code Here

    boolean order=false;
    try {
      ValueEval ve = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
      result = OperandResolver.coerceValueToDouble(ve);
      if (Double.isNaN(result) || Double.isInfinite(result)) {
        throw new EvaluationException(ErrorEval.NUM_ERROR);
      }
      aeRange = convertRangeArg(arg1);
     
      ve = OperandResolver.getSingleValue(arg2, srcRowIndex, srcColumnIndex);
      int order_value = OperandResolver.coerceValueToInt(ve);
      if(order_value==0){
        order=true;
      }else if(order_value==1){
        order=false;
      }else throw new EvaluationException(ErrorEval.NUM_ERROR);
     
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
    return eval(srcRowIndex, srcColumnIndex, result, aeRange, order);
View Full Code Here

TOP

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