Package org.apache.poi.ss.formula.functions.LookupUtils

Examples of org.apache.poi.ss.formula.functions.LookupUtils.ValueVector


    if (eval instanceof RefEval) {
      RefEval re = (RefEval) eval;
      return new SingleValueVector(re.getInnerValueEval());
    }
    if (eval instanceof TwoDEval) {
      ValueVector result = LookupUtils.createVector((TwoDEval)eval);
      if (result == null) {
        throw new EvaluationException(ErrorEval.NA);
      }
      return result;
    }
View Full Code Here


 
  public ValueEval evaluate(int srcRowIndex, int srcColumnIndex,
      ValueEval arg0, ValueEval arg1) {
    double result;
    try {
      ValueVector vvX = createValueVector(arg0);
      ValueVector vvY = createValueVector(arg1);
      int size = vvX.getSize();
      if (size == 0 || vvY.getSize() != size) {
        return ErrorEval.NA;
      }
      result = evaluateInternal(vvX, vvY, size);
    } catch (EvaluationException e) {
      return e.getErrorEval();
View Full Code Here

  public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {

    double result;
    try {
      ValueVector vvX = createValueVector(arg0);
      ValueVector vvY = createValueVector(arg1);
      int size = vvX.getSize();
      if (size == 0 || vvY.getSize() != size) {
        return ErrorEval.NA;
      }
      result = evaluateInternal(vvX, vvY, size);
    } catch (EvaluationException e) {
      return e.getErrorEval();
View Full Code Here

      ValueEval lookupValue = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
      TwoDEval tableArray = LookupUtils.resolveTableArrayArg(arg1);
      boolean isRangeLookup = LookupUtils.resolveRangeLookupArg(arg3, srcRowIndex, srcColumnIndex);
      int rowIndex = LookupUtils.lookupIndexOfValue(lookupValue, LookupUtils.createColumnVector(tableArray, 0), isRangeLookup);
      int colIndex = LookupUtils.resolveRowOrColIndexArg(arg2, srcRowIndex, srcColumnIndex);
      ValueVector resultCol = createResultColumnVector(tableArray, colIndex);
      return resultCol.getItem(rowIndex);
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
  }
View Full Code Here

    try {
      ValueEval lookupValue = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
      TwoDEval aeLookupVector = LookupUtils.resolveTableArrayArg(arg1);
      TwoDEval aeResultVector = LookupUtils.resolveTableArrayArg(arg2);

      ValueVector lookupVector = createVector(aeLookupVector);
      ValueVector resultVector = createVector(aeResultVector);
      if(lookupVector.getSize() > resultVector.getSize()) {
        // Excel seems to handle this by accessing past the end of the result vector.
        throw new RuntimeException("Lookup vector and result vector of differing sizes not supported yet");
      }
      int index = LookupUtils.lookupIndexOfValue(lookupValue, lookupVector, true);

      return resultVector.getItem(index);
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
  }
View Full Code Here

      return e.getErrorEval();
    }
  }

  private static ValueVector createVector(TwoDEval ae) {
    ValueVector result = LookupUtils.createVector(ae);
    if (result != null) {
      return result;
    }
    // extra complexity required to emulate the way LOOKUP can handles these abnormal cases.
    throw new RuntimeException("non-vector lookup or result areas not supported yet");
View Full Code Here

    // Note - Excel does not strictly require -1 and +1
    boolean findLargestLessThanOrEqual = match_type > 0;

    try {
      ValueEval lookupValue = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
      ValueVector lookupRange = evaluateLookupRange(arg1);
      int index = findIndexOfValue(lookupValue, lookupRange, matchExact, findLargestLessThanOrEqual);
      return new NumberEval(index + 1); // +1 to convert to 1-based
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
View Full Code Here

    if (eval instanceof RefEval) {
      RefEval re = (RefEval) eval;
      return new SingleValueVector(re.getInnerValueEval());
    }
    if (eval instanceof TwoDEval) {
      ValueVector result = LookupUtils.createVector((TwoDEval)eval);
      if (result == null) {
        throw new EvaluationException(ErrorEval.NA);
      }
      return result;
    }
View Full Code Here

      ValueEval lookupValue = OperandResolver.getSingleValue(arg0, srcRowIndex, srcColumnIndex);
      TwoDEval tableArray = LookupUtils.resolveTableArrayArg(arg1);
      boolean isRangeLookup = LookupUtils.resolveRangeLookupArg(arg3, srcRowIndex, srcColumnIndex);
      int colIndex = LookupUtils.lookupIndexOfValue(lookupValue, LookupUtils.createRowVector(tableArray, 0), isRangeLookup);
      int rowIndex = LookupUtils.resolveRowOrColIndexArg(arg2, srcRowIndex, srcColumnIndex);
      ValueVector resultCol = createResultColumnVector(tableArray, rowIndex);
      return resultCol.getItem(colIndex);
    } catch (EvaluationException e) {
      return e.getErrorEval();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.functions.LookupUtils.ValueVector

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.