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

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


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


  }

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

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

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

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

      }
      return new NumberEval(result);
    }
    protected final double eval(ValueEval[] args, int srcCellRow, int srcCellCol) throws EvaluationException {
      if (args.length != 1) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      double d = singleOperandEvaluate(args[0], srcCellRow, srcCellCol);
      return evaluate(d);
    }
View Full Code Here

    } else {
      // ae is an area (not single row or column)
      if (!colArgWasPassed) {
        // always an error with 2-D area refs
        // Note - the type of error changes if the pRowArg is negative
        throw new EvaluationException(pRowIx < 0 ? ErrorEval.VALUE_INVALID : ErrorEval.REF_INVALID);
      }
      // Normal case - area ref is 2-D, and both index args were provided
      // if either arg is missing (or blank) the logic is similar to OperandResolver.getSingleValue()
      if (rowArgWasEmpty) {
        rowIx = srcRowIx - ae.getFirstRow();
      } else {
        rowIx = pRowIx-1;
      }
      if (colArgWasEmpty) {
        columnIx = srcColIx - ae.getFirstColumn();
      } else {
        columnIx = pColumnIx-1;
      }
    }

    int width = ae.getWidth();
    int height = ae.getHeight();
    // Slightly irregular logic for bounds checking errors
    if (!rowArgWasEmpty && rowIx >= height || !colArgWasEmpty && columnIx >= width) {
      // high bounds check fail gives #REF! if arg was explicitly passed
      throw new EvaluationException(ErrorEval.REF_INVALID);
    }
    if (rowIx < 0 || columnIx < 0 || rowIx >= height || columnIx >= width) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    return ae.getRelativeValue(rowIx, columnIx);
  }
View Full Code Here

    if (ev == BlankEval.instance) {
      return 0;
    }
    int result = OperandResolver.coerceValueToInt(ev);
    if (result < 0) {
      throw new EvaluationException(ErrorEval.VALUE_INVALID);
    }
    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

    }
    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

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.