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

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


   * @param eval
   */
  private CellValue evaluateFormulaCellValue(Cell cell) {
    ValueEval eval = _bookEvaluator.evaluate(new HSSFEvaluationCell((HSSFCell)cell));
    if (eval instanceof NumberEval) {
      NumberEval ne = (NumberEval) eval;
      return new CellValue(ne.getNumberValue());
    }
    if (eval instanceof BoolEval) {
      BoolEval be = (BoolEval) eval;
      return CellValue.valueOf(be.getBooleanValue());
    }
    if (eval instanceof StringEval) {
      StringEval ne = (StringEval) eval;
      return new CellValue(ne.getStringValue());
    }
    if (eval instanceof ErrorEval) {
      return CellValue.getError(((ErrorEval)eval).getErrorCode());
    }
    throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
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

    if (ptg instanceof NameXPtg) {
       return ec.getNameXEval(((NameXPtg) ptg));
    }

    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

                    " Only XSSFCells can be evaluated.");
        }

    ValueEval eval = _bookEvaluator.evaluate(new XSSFEvaluationCell((XSSFCell) cell));
    if (eval instanceof NumberEval) {
      NumberEval ne = (NumberEval) eval;
      return new CellValue(ne.getNumberValue());
    }
    if (eval instanceof BoolEval) {
      BoolEval be = (BoolEval) eval;
      return CellValue.valueOf(be.getBooleanValue());
    }
    if (eval instanceof StringEval) {
      StringEval ne = (StringEval) eval;
      return new CellValue(ne.getStringValue());
    }
    if (eval instanceof ErrorEval) {
      return CellValue.getError(((ErrorEval)eval).getErrorCode());
    }
    throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
View Full Code Here

      return e.getErrorEval();
    }
    if (val < 0) {
      return ErrorEval.NUM_ERROR;
    }
    return new NumberEval(getCalField(val));
  }
View Full Code Here

  };

  private static void confirmSubtotal(int function, double expected) {
    ValueEval[] values = new ValueEval[TEST_VALUES0.length];
    for (int i = 0; i < TEST_VALUES0.length; i++) {
      values[i] = new NumberEval(TEST_VALUES0[i]);
    }

    AreaEval arg1 = EvalFactory.createAreaEval("C1:D5", values);
    ValueEval args[] = { new NumberEval(function), arg1 };

    ValueEval result = new Subtotal().evaluate(args, 0, 0);

    assertEquals(NumberEval.class, result.getClass());
    assertEquals(expected, ((NumberEval) result).getNumberValue(), 0.0);
View Full Code Here

                new ValueEval[]{ new StringEval("Potato"), new StringEval("Cucumber") }, EC));
    }

    public void testReturnWorkdays() {
        assertEquals(new Date(109, APRIL, 30), DateUtil.getJavaDate(((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{
                new StringEval(STARTING_DATE), new NumberEval(151) }, EC)).getNumberValue()));
    }
View Full Code Here

      String startDate = "2013/09/30";
      int days = -1;
      String expectedWorkDay = "2013/09/27";
    StringEval stringEval = new StringEval(startDate);
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{
                stringEval, new NumberEval(days) }, EC)).getNumberValue();
    assertEquals(expectedWorkDay, formatter.format(DateUtil.getJavaDate(numberValue)));
    }
View Full Code Here

      String startDate = "2013/09/27";
      int days = 1;
      String expectedWorkDay = "2013/09/30";
    StringEval stringEval = new StringEval(startDate);
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{
                stringEval, new NumberEval(days) }, EC)).getNumberValue();
    assertEquals(expectedWorkDay, formatter.format(DateUtil.getJavaDate(numberValue)));
    }
View Full Code Here

      String startDate = "2013/10/06";
      int days = 1;
      String expectedWorkDay = "2013/10/07";
    StringEval stringEval = new StringEval(startDate);
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(new ValueEval[]{
                stringEval, new NumberEval(days) }, EC)).getNumberValue();
    assertEquals(expectedWorkDay, formatter.format(DateUtil.getJavaDate(numberValue)));
    }
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.