Package org.apache.poi.ss.formula

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


      ValueEval col_index, ValueEval range_lookup) {
    try {
      // Evaluation order:
      // lookup_value , table_array, range_lookup, find lookup value, col_index, fetch result
      ValueEval lookupValue = OperandResolver.getSingleValue(lookup_value, srcRowIndex, srcColumnIndex);
      TwoDEval tableArray = LookupUtils.resolveTableArrayArg(table_array);
      boolean isRangeLookup = LookupUtils.resolveRangeLookupArg(range_lookup, srcRowIndex, srcColumnIndex);
      int rowIndex = LookupUtils.lookupIndexOfValue(lookupValue, LookupUtils.createColumnVector(tableArray, 0), isRangeLookup);
      int colIndex = LookupUtils.resolveRowOrColIndexArg(col_index, srcRowIndex, srcColumnIndex);
      ValueVector resultCol = createResultColumnVector(tableArray, colIndex);
      return resultCol.getItem(rowIndex);
View Full Code Here


   * Collects values from a single argument
   */
  private void collectValues(ValueEval operand, DoubleList temp) throws EvaluationException {

    if (operand instanceof TwoDEval) {
      TwoDEval ae = (TwoDEval) operand;
      int width = ae.getWidth();
      int height = ae.getHeight();
      for (int rrIx=0; rrIx<height; rrIx++) {
        for (int rcIx=0; rcIx<width; rcIx++) {
          ValueEval ve = ae.getValue(rrIx, rcIx);
                    if(!isSubtotalCounted() && ae.isSubTotal(rrIx, rcIx)) continue;
                    collectValue(ve, true, temp);
        }
      }
      return;
    }
View Full Code Here

      }
      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

      // 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

    }
  }

  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

    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

                }
            }
            return;
        }
    if (operand instanceof TwoDEval) {
      TwoDEval ae = (TwoDEval) operand;
      int width = ae.getWidth();
      int height = ae.getHeight();
      for (int rrIx=0; rrIx<height; rrIx++) {
        for (int rcIx=0; rcIx<width; rcIx++) {
          ValueEval ve = ae.getValue(rrIx, rcIx);
                    if(!isSubtotalCounted() && ae.isSubTotal(rrIx, rcIx)) continue;
                    collectValue(ve, true, temp);
        }
      }
      return;
    }
View Full Code Here

     */
    for (int i=0, iSize=args.length; i<iSize; i++) {
            Boolean tempVe;
      ValueEval arg = args[i];
      if (arg instanceof TwoDEval) {
        TwoDEval ae = (TwoDEval) arg;
        int height = ae.getHeight();
        int width = ae.getWidth();
        for (int rrIx=0; rrIx<height; rrIx++) {
          for (int rcIx=0; rcIx<width; rcIx++) {
            ValueEval ve = ae.getValue(rrIx, rcIx);
            tempVe = OperandResolver.coerceValueToBoolean(ve, true);
            if (tempVe != null) {
              result = partialEvaluate(result, tempVe.booleanValue());
              atleastOneNonBlank = true;
            }
View Full Code Here

      ValueEval col_index, ValueEval range_lookup) {
    try {
      // Evaluation order:
      // lookup_value , table_array, range_lookup, find lookup value, col_index, fetch result
      ValueEval lookupValue = OperandResolver.getSingleValue(lookup_value, srcRowIndex, srcColumnIndex);
      TwoDEval tableArray = LookupUtils.resolveTableArrayArg(table_array);
      boolean isRangeLookup = LookupUtils.resolveRangeLookupArg(range_lookup, srcRowIndex, srcColumnIndex);
      int rowIndex = LookupUtils.lookupIndexOfValue(lookupValue, LookupUtils.createColumnVector(tableArray, 0), isRangeLookup);
      int colIndex = LookupUtils.resolveRowOrColIndexArg(col_index, srcRowIndex, srcColumnIndex);
      ValueVector resultCol = createResultColumnVector(tableArray, colIndex);
      return resultCol.getItem(rowIndex);
View Full Code Here

     * Note: no short-circuit boolean loop exit because any ErrorEvals will override the result
     */
    for (int i=0, iSize=args.length; i<iSize; i++) {
      ValueEval arg = args[i];
      if (arg instanceof TwoDEval) {
        TwoDEval ae = (TwoDEval) arg;
        int height = ae.getHeight();
        int width = ae.getWidth();
        for (int rrIx=0; rrIx<height; rrIx++) {
          for (int rcIx=0; rcIx<width; rcIx++) {
            ValueEval ve = ae.getValue(rrIx, rcIx);
            Boolean tempVe = OperandResolver.coerceValueToBoolean(ve, true);
            if (tempVe != null) {
              result = partialEvaluate(result, tempVe.booleanValue());
              atleastOneNonBlank = true;
            }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.TwoDEval

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.