Package org.apache.poi.ss.formula.eval

Examples of org.apache.poi.ss.formula.eval.NumberEval


    static final int OCTAL_BASE = 8;

    public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval numberVE) {
        String octal = OperandResolver.coerceValueToString(numberVE);
        try {
           return new NumberEval(BaseNumberUtils.convertToDecimal(octal, OCTAL_BASE, MAX_NUMBER_OF_PLACES));
        catch (IllegalArgumentException e) {
            return ErrorEval.NUM_ERROR;
        }
    }
View Full Code Here


    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

      return e.getErrorEval();
    }
    if (Double.isNaN(result) || Double.isInfinite(result)) {
      return ErrorEval.NUM_ERROR;
    }
    return new NumberEval(result);
  }
View Full Code Here

        }
      }
      // only count pairs if both elements are numbers
      if (vx instanceof NumberEval && vy instanceof NumberEval) {
        accumlatedSome = true;
        NumberEval nx = (NumberEval) vx;
        NumberEval ny = (NumberEval) vy;
        sumx  += nx.getNumberValue();
              sumy  += ny.getNumberValue();
      } else {
        // all other combinations of value types are silently ignored
      }
    }
    double xbar = sumx / size;
        double ybar = sumy / size;
   
     // second pass: compute summary statistics
        double xxbar = 0.0, xybar = 0.0;
        for (int i = 0; i < size; i++) {
      ValueEval vx = x.getItem(i);
      ValueEval vy = y.getItem(i);
     
      if (vx instanceof ErrorEval) {
        if (firstXerr == null) {
          firstXerr = (ErrorEval) vx;
          continue;
        }
      }
      if (vy instanceof ErrorEval) {
        if (firstYerr == null) {
          firstYerr = (ErrorEval) vy;
          continue;
        }
      }
     
      // only count pairs if both elements are numbers
      if (vx instanceof NumberEval && vy instanceof NumberEval) {
        NumberEval nx = (NumberEval) vx;
        NumberEval ny = (NumberEval) vy;
              xxbar += (nx.getNumberValue() - xbar) * (nx.getNumberValue() - xbar);
              xybar += (nx.getNumberValue() - xbar) * (ny.getNumberValue() - ybar);
      } else {
        // all other combinations of value types are silently ignored
      }
        }
        double beta1 = xybar / xxbar;
View Full Code Here

       } catch (RuntimeException re) {
         if (re.getCause() instanceof WorkbookNotFoundException && _ignoreMissingWorkbooks) {
           logInfo(re.getCause().getMessage() + " - Continuing with cached value!");
           switch(srcCell.getCachedFormulaResultType()) {
             case Cell.CELL_TYPE_NUMERIC:
               result = new NumberEval(srcCell.getNumericCellValue());
               break;
             case Cell.CELL_TYPE_STRING:
               result =  new StringEval(srcCell.getStringCellValue());
               break;
             case Cell.CELL_TYPE_BLANK:
View Full Code Here

      return BlankEval.instance;
    }
    int cellType = cell.getCellType();
    switch (cellType) {
      case Cell.CELL_TYPE_NUMERIC:
        return new NumberEval(cell.getNumericCellValue());
      case Cell.CELL_TYPE_STRING:
        return new StringEval(cell.getStringCellValue());
      case Cell.CELL_TYPE_BOOLEAN:
        return BoolEval.valueOf(cell.getBooleanCellValue());
      case Cell.CELL_TYPE_BLANK:
View Full Code Here

           // Externally defined named ranges or macro functions
           return processNameEval(ec.getNameXEval((NameXPxg)ptg), ec);
       }

       if (ptg instanceof IntPtg) {
           return new NumberEval(((IntPtg)ptg).getValue());
       }
       if (ptg instanceof NumberPtg) {
           return new NumberEval(((NumberPtg)ptg).getValue());
       }
       if (ptg instanceof StringPtg) {
           return new StringEval(((StringPtg) ptg).getValue());
       }
       if (ptg instanceof BoolPtg) {
View Full Code Here

    } else if (arg0 instanceof ThreeDEval) {
      result = CountUtils.countMatchingCellsInArea((ThreeDEval) arg0, predicate);
    } else {
      throw new IllegalArgumentException("Bad range arg type (" + arg0.getClass().getName() + ")");
    }
    return new NumberEval(result);
  }
View Full Code Here

      return e.getErrorEval();
    }
    if (Double.isNaN(result) || Double.isInfinite(result)) {
      return ErrorEval.NUM_ERROR;
    }
    return new NumberEval(result);
  }
View Full Code Here

        }
      }
      // only count pairs if both elements are numbers
      if (vx instanceof NumberEval && vy instanceof NumberEval) {
        accumlatedSome = true;
        NumberEval nx = (NumberEval) vx;
        NumberEval ny = (NumberEval) vy;
        result += acc.accumulate(nx.getNumberValue(), ny.getNumberValue());
      } else {
        // all other combinations of value types are silently ignored
      }
    }
    if (firstXerr != null) {
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.eval.NumberEval

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.