Examples of AreaEval


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

        case 1:
            if (operands[0] instanceof ErrorEval) {
                b = true;
            }
            else if (operands[0] instanceof AreaEval) {
                AreaEval ae = (AreaEval) operands[0];
                if (ae.contains(srcCellRow, srcCellCol)) { // circular ref!
                    retval = ErrorEval.CIRCULAR_REF_ERROR;
                }
                else if (ae.isRow()) {
                    if (ae.containsColumn(srcCellCol)) {
                        ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCellCol);
                        if (ve instanceof RefEval)
                            b = ((RefEval) ve).getInnerValueEval() instanceof ErrorEval;
                        else
                            b = (ve instanceof ErrorEval);
                    }
                    else {
                        b = true;
                    }
                }
                else if (ae.isColumn()) {
                    if (ae.containsRow(srcCellRow)) {
                        ValueEval ve = ae.getValueAt(srcCellRow, ae.getFirstColumn());
                        if (ve instanceof RefEval)
                            b = ((RefEval) ve).getInnerValueEval() instanceof ErrorEval;
                        else
                            b = (ve instanceof ErrorEval);
                    }
View Full Code Here

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

    }
    try {
      // Evaluation order:
      // arg0 lookup_value, arg1 table_array, arg3 range_lookup, find lookup value, arg2 row_index, fetch result
      ValueEval lookupValue = OperandResolver.getSingleValue(args[0], srcCellRow, srcCellCol);
      AreaEval tableArray = LookupUtils.resolveTableArrayArg(args[1]);
      boolean isRangeLookup = LookupUtils.resolveRangeLookupArg(arg3, srcCellRow, srcCellCol);
      int colIndex = LookupUtils.lookupIndexOfValue(lookupValue, LookupUtils.createRowVector(tableArray, 0), isRangeLookup);
      int rowIndex = LookupUtils.resolveRowOrColIndexArg(args[2], srcCellRow, srcCellCol);
      ValueVector resultCol = createResultColumnVector(tableArray, rowIndex);
      return resultCol.getItem(colIndex);
View Full Code Here

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

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

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

    if (eval == null) {
      throw new RuntimeException("parameter may not be null");
    }
    if (eval instanceof AreaEval) {
      AreaEval ae = (AreaEval) eval;
      // an area ref can work as a scalar value if it is 1x1
      if(!ae.isColumn() || !ae.isRow()) {
        throw new EvaluationException(ErrorEval.VALUE_INVALID);
      }
      eval = ae.getRelativeValue(0, 0);
    }

    if (!(eval instanceof ValueEval)) {
      throw new RuntimeException("Unexpected value eval class ("
          + eval.getClass().getName() + ")");
View Full Code Here

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

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


    AreaEval 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.hssf.record.formula.eval.AreaEval

    }
  }

  private static boolean areasAllSameSize(AreaEval[] args, int height, int width) {
    for (int i = 0; i < args.length; i++) {
      AreaEval 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.hssf.record.formula.eval.AreaEval

    }
    Eval firstArg = args[0];

    int result;
    if (firstArg instanceof AreaEval) {
      AreaEval ae = (AreaEval) firstArg;
      result = ae.getLastColumn() - ae.getFirstColumn() + 1;
    } else if (firstArg instanceof RefEval) {
      result = 1;
    } else { // anything else is not valid argument
      return ErrorEval.VALUE_INVALID;
    }
View Full Code Here

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

    return new NumberEval(result);
  }

  private static void collectValues(Eval arg, List<Double> temp) throws EvaluationException {
    if (arg instanceof AreaEval) {
      AreaEval ae = (AreaEval) 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.getRelativeValue(rrIx, rcIx);
          collectValue(ve1, temp, false);
        }
      }
      return;
    }
View Full Code Here

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

  public Eval evaluate(Eval[] args, int srcRowIndex, short srcColumnIndex) {
    if (args.length < 2) {
      return ErrorEval.VALUE_INVALID;
    }

    AreaEval aeRange;
    AreaEval aeSum;
    try {
      aeRange = convertRangeArg(args[0]);

      switch (args.length) {
        case 2:
View Full Code Here

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

    }
    try {
      // Evaluation order:
      // arg0 lookup_value, arg1 table_array, arg3 range_lookup, find lookup value, arg2 col_index, fetch result
      ValueEval lookupValue = OperandResolver.getSingleValue(args[0], srcCellRow, srcCellCol);
      AreaEval tableArray = LookupUtils.resolveTableArrayArg(args[1]);
      boolean isRangeLookup = LookupUtils.resolveRangeLookupArg(arg3, srcCellRow, srcCellCol);
      int rowIndex = LookupUtils.lookupIndexOfValue(lookupValue, LookupUtils.createColumnVector(tableArray, 0), isRangeLookup);
      int colIndex = LookupUtils.resolveRowOrColIndexArg(args[2], srcCellRow, srcCellCol);
      ValueVector resultCol = createResultColumnVector(tableArray, colIndex);
      return resultCol.getItem(rowIndex);
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.