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

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


   
    ValueEval v0 = new NumberEval(2.0);
    ValueEval v1 = new StringEval("abc");
    ValueEval v2 = ErrorEval.DIV_ZERO;
   
    AreaEval ev = EvalFactory.createAreaEval("A10:A12", new ValueEval[] { v0, v1, v2, });
   
    I_MatchPredicate mp;
    mp = Countif.createCriteriaPredicate(ev, 9, srcColIx);
    confirmPredicate(true, mp, srcColIx);
    confirmPredicate(false, mp, "abc");
View Full Code Here


                HSSFCell cell = (row != null) ? row.getCell(colIx) : null;
                stack.push(createRef3DEval(refPtg, cell, row, xsheet, workbook));
            }
            else if (ptg instanceof AreaPtg) {
                AreaPtg ap = (AreaPtg) ptg;
                AreaEval ae = evaluateAreaPtg(sheet, workbook, ap);
                stack.push(ae);
            }
            else if (ptg instanceof Area3DPtg) {
                Area3DPtg a3dp = (Area3DPtg) ptg;
                AreaEval ae = evaluateArea3dPtg(workbook, a3dp);
                stack.push(ae);
            }
            else {
                Eval ptgEval = getEvalForPtg(ptg);
                stack.push(ptgEval);
View Full Code Here

        if (evaluationResult instanceof RefEval) {
            RefEval rv = (RefEval) evaluationResult;
            return rv.getInnerValueEval();
        }
        if (evaluationResult instanceof AreaEval) {
            AreaEval ae = (AreaEval) evaluationResult;
            if (ae.isRow()) {
                if(ae.isColumn()) {
                    return ae.getValues()[0];
                }
                return ae.getValueAt(ae.getFirstRow(), srcColNum);
            }
            if (ae.isColumn()) {
                return ae.getValueAt(srcRowNum, ae.getFirstColumn());
            }
            return ErrorEval.VALUE_INVALID;
        }
        return evaluationResult;
    }
View Full Code Here

    return new NumberEval(temp);
  }

  private static int countArg(Eval eval) {
        if (eval instanceof AreaEval) {
            AreaEval ae = (AreaEval) eval;
            return countAreaEval(ae);
        }
        if (eval instanceof RefEval) {
            RefEval refEval = (RefEval)eval;
      return countValue(refEval.getInnerValueEval());
View Full Code Here

    if (eval instanceof RefEval) {
      RefEval re = (RefEval) eval;
      return new ValueEval[] { re.getInnerValueEval(), };
    }
    if (eval instanceof AreaEval) {
      AreaEval ae = (AreaEval) eval;
      if(!ae.isColumn() && !ae.isRow()) {
        throw new EvaluationException(ErrorEval.NA);
      }
      return ae.getValues();
    }
   
    // Error handling for lookup_range arg is also unusual
    if(eval instanceof NumericValueEval) {
      throw new EvaluationException(ErrorEval.NA);
View Full Code Here

    return new NumberEval(temp);
  }

  private static int countArg(Eval eval) {
        if (eval instanceof AreaEval) {
            AreaEval ae = (AreaEval) eval;
            return countAreaEval(ae);
        }
        if (eval instanceof RefEval) {
            RefEval refEval = (RefEval)eval;
      return countValue(refEval.getInnerValueEval());
View Full Code Here

    }
    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, new ColumnVector(tableArray, 0), isRangeLookup);
      ValueEval veColIndex = OperandResolver.getSingleValue(args[2], srcCellRow, srcCellCol);
      int colIndex = LookupUtils.resolveRowOrColIndexArg(veColIndex);
      ValueVector resultCol = createResultColumnVector(tableArray, colIndex);
View Full Code Here

      // too few arguments
      return ErrorEval.VALUE_INVALID;
    }
    Eval firstArg = args[0];
    if(firstArg instanceof AreaEval) {
      AreaEval reference = (AreaEval) firstArg;
     
      int rowIx = 0;
      int columnIx = 0;
      int areaIx = 0;
      switch(nArgs) {
        case 4:
          areaIx = convertIndexArgToZeroBase(args[3]);
          throw new RuntimeException("Incomplete code" +
              " - don't know how to support the 'area_num' parameter yet)");
          // Excel expression might look like this "INDEX( (A1:B4, C3:D6, D2:E5 ), 1, 2, 3)
          // In this example, the 3rd area would be used i.e. D2:E5, and the overall result would be E2
          // Token array might be encoded like this: MemAreaPtg, AreaPtg, AreaPtg, UnionPtg, UnionPtg, ParenthesesPtg
          // The formula parser doesn't seem to support this yet. Not sure if the evaluator does either
         
        case 3:
          columnIx = convertIndexArgToZeroBase(args[2]);
        case 2:
          rowIx = convertIndexArgToZeroBase(args[1]);
          break;
        default:
          // too many arguments
          return ErrorEval.VALUE_INVALID;
      }
     
          int nColumns = reference.getLastColumn()-reference.getFirstColumn()+1;
      int index = rowIx * nColumns + columnIx;
     
      return reference.getValues()[index];
    }
   
    // else the other variation of this function takes an array as the first argument
    // it seems like interface 'ArrayEval' does not even exist yet
   
View Full Code Here

     * @param srcCol
     */
    protected double[] getNumberArray(Eval operand, int srcRow, short srcCol) {
       
        if (operand instanceof AreaEval) {
            AreaEval ae = (AreaEval) operand;
            ValueEval[] values = ae.getValues();
            DoubleList retval = new DoubleList();
            for (int j=0, jSize=values.length; j<jSize; j++) {
                /*
                 * TODO: For an AreaEval, we are constructing a RefEval
                 * per element.
View Full Code Here

    }
   
    protected ValueEval singleOperandEvaluate(Eval eval, int srcRow, short srcCol) {
        ValueEval retval;
        if (eval instanceof AreaEval) {
            AreaEval ae = (AreaEval) eval;
            if (ae.contains(srcRow, srcCol)) { // circular ref!
                retval = ErrorEval.CIRCULAR_REF_ERROR;
            }
            else if (ae.isRow()) {
                if (ae.containsColumn(srcCol)) {
                    ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCol);
                    ve = getXlator().attemptXlateToNumeric(ve);
                    retval = getXlator().attemptXlateToNumeric(ve);
                }
                else {
                    retval = ErrorEval.VALUE_INVALID;
                }
            }
            else if (ae.isColumn()) {
                if (ae.containsRow(srcRow)) {
                    ValueEval ve = ae.getValueAt(srcRow, ae.getFirstColumn());
                    retval = getXlator().attemptXlateToNumeric(ve);
                }
                else {
                    retval = ErrorEval.VALUE_INVALID;
                }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.formula.eval.AreaEval

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.