Examples of TwoDEval


Examples of org.apache.poi.ss.formula.TwoDEval

      }
      if(firstArg instanceof RefEval) {
        return evaluateSingleProduct(args);
      }
      if (firstArg instanceof TwoDEval) {
        TwoDEval ae = (TwoDEval) firstArg;
        if(ae.isRow() && ae.isColumn()) {
          return evaluateSingleProduct(args);
        }
        return evaluateAreaSumProduct(args);
      }
    } catch (EvaluationException e) {
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

      // one of the other args was not an AreaRef
      return ErrorEval.VALUE_INVALID;
    }


    TwoDEval firstArg = args[0];

    int height = firstArg.getHeight();
    int width = firstArg.getWidth(); // TODO - junit

    // first check dimensions
    if (!areasAllSameSize(args, height, width)) {
      // normally this results in #VALUE!,
      // but errors in individual cells take precedence
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

    }
  }

  private static boolean areasAllSameSize(TwoDEval[] args, int height, int width) {
    for (int i = 0; i < args.length; i++) {
      TwoDEval areaEval = args[i];
      // check that height and width match
      if(areaEval.getHeight() != height) {
        return false;
      }
      if(areaEval.getWidth() != width) {
        return false;
      }
    }
    return true;
  }
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

    return new NumberEval(result);
  }

  private static void collectValues(ValueEval arg, List<Double> temp) throws EvaluationException {
    if (arg instanceof TwoDEval) {
      TwoDEval ae = (TwoDEval) arg;
      int width = ae.getWidth();
      int height = ae.getHeight();
      for (int rrIx = 0; rrIx < height; rrIx++) {
        for (int rcIx = 0; rcIx < width; rcIx++) {
          ValueEval ve1 = ae.getValue(rrIx, rcIx);
          collectValue(ve1, temp, false);
        }
      }
      return;
    }
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

      ValueEval arg2, ValueEval arg3) {
    try {
      // Evaluation order:
      // arg0 lookup_value, arg1 table_array, arg3 range_lookup, find lookup value, arg2 col_index, fetch result
      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);
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

    return new NumberEval(result);
  }

  private static void collectValues(ValueEval arg, List<Double> temp) throws EvaluationException {
    if (arg instanceof TwoDEval) {
      TwoDEval ae = (TwoDEval) arg;
      int width = ae.getWidth();
      int height = ae.getHeight();
      for (int rrIx = 0; rrIx < height; rrIx++) {
        for (int rcIx = 0; rcIx < width; rcIx++) {
          ValueEval ve1 = ae.getValue(rrIx, rcIx);
          collectValue(ve1, temp, false);
        }
      }
      return;
    }
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

  public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
      ValueEval arg2) {
    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.
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

* @author Josh Micich
*/
public final class Index implements Function2Arg, Function3Arg, Function4Arg {

  public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
    TwoDEval reference = convertFirstArg(arg0);

    int columnIx = 0;
    try {
      int rowIx = resolveIndexArg(arg1, srcRowIndex, srcColumnIndex);

      if (!reference.isColumn()) {
        if (!reference.isRow()) {
          // always an error with 2-D area refs
          // Note - the type of error changes if the pRowArg is negative
          return ErrorEval.REF_INVALID;
        }
        // When the two-arg version of INDEX() has been invoked and the reference
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

      return e.getErrorEval();
    }
  }
  public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
      ValueEval arg2) {
    TwoDEval reference = convertFirstArg(arg0);

    try {
      int columnIx = resolveIndexArg(arg2, srcRowIndex, srcColumnIndex);
      int rowIx = resolveIndexArg(arg1, srcRowIndex, srcColumnIndex);
      return getValueFromArea(reference, rowIx, columnIx);
View Full Code Here

Examples of org.apache.poi.ss.formula.TwoDEval

  private static ValueEval getValueFromArea(TwoDEval ae, int pRowIx, int pColumnIx)
      throws EvaluationException {
    assert pRowIx >= 0;
    assert pColumnIx >= 0;

    TwoDEval result = ae;

    if (pRowIx != 0) {
      // Slightly irregular logic for bounds checking errors
      if (pRowIx > ae.getHeight()) {
        // high bounds check fail gives #REF! if arg was explicitly passed
        throw new EvaluationException(ErrorEval.REF_INVALID);
      }
      result = result.getRow(pRowIx-1);
    }

    if (pColumnIx != 0) {
      // Slightly irregular logic for bounds checking errors
      if (pColumnIx > ae.getWidth()) {
        // high bounds check fail gives #REF! if arg was explicitly passed
        throw new EvaluationException(ErrorEval.REF_INVALID);
      }
      result = result.getColumn(pColumnIx-1);
    }
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.