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

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


    }
  }

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


      result = performBinarySearch(vector, lookupComparer);
    } else {
      result = lookupIndexOfExactValue(lookupComparer, vector);
    }
    if(result < 0) {
      throw new EvaluationException(ErrorEval.NA);
    }
    return result;
  }
View Full Code Here

        atleastOneNonBlank = true;
      }
    }

    if (!atleastOneNonBlank) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    return result;
  }
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

     * @throws EvaluationException exception upon parsing.
     */
    public 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

      } 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 TwoDEval) {
      return new AreaValueArray((TwoDEval) arg);
    }
    if (arg instanceof RefEval) {
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

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.