Package org.apache.poi.hssf.usermodel

Examples of org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluate()


        for (int rowNum : resultRows) {
            HSSFRow row = sheet.getRow(rowNum);
            HSSFCell cellA = row.getCell(0);
            try {
                CellValue cv = fe.evaluate(cellA);
                assertFormulaResult(cv, cellA);
            } catch (Throwable e) {
                if (failures.length() > 0) failures.append('\n');
                failures.append("Row[").append(cellA.getRowIndex() + 1).append("]: ").append(cellA.getCellFormula()).append(" ");
                failures.append(e.getMessage());
View Full Code Here


            }
        }

        HSSFRow row = sheet.getRow(37);
        HSSFCell cellA = row.getCell(0);
        CellValue cv = fe.evaluate(cellA);
        assertEquals(ErrorEval.DIV_ZERO.getErrorCode(), cv.getErrorValue());

        if (failures.length() > 0) {
            throw new AssertionFailedError(failureCount + " IRR assertions failed:\n" + failures.toString());
        }
View Full Code Here

        HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);

        HSSFSheet example1 = wb.getSheet("Example 1");
        HSSFCell a8 = example1.getRow(7).getCell(0);
        assertEquals("INTERCEPT(A2:A6,B2:B6)", a8.getCellFormula());
        fe.evaluate(a8);
        assertEquals(0.048387097, a8.getNumericCellValue(), 0.000000001);

    }
}
View Full Code Here

        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("finance.xls");
        HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);

        HSSFSheet example1 = wb.getSheet("IPMT");
        HSSFCell ex1cell1 = example1.getRow(6).getCell(0);
        fe.evaluate(ex1cell1);
        assertEquals(-22.41, ex1cell1.getNumericCellValue(), 0.1);

        HSSFCell ex1cell2 = example1.getRow(7).getCell(0);
        fe.evaluate(ex1cell2);
        assertEquals(-292.45, ex1cell2.getNumericCellValue(), 0.1);
View Full Code Here

        HSSFCell ex1cell1 = example1.getRow(6).getCell(0);
        fe.evaluate(ex1cell1);
        assertEquals(-22.41, ex1cell1.getNumericCellValue(), 0.1);

        HSSFCell ex1cell2 = example1.getRow(7).getCell(0);
        fe.evaluate(ex1cell2);
        assertEquals(-292.45, ex1cell2.getNumericCellValue(), 0.1);

    }
}
View Full Code Here

   */
  private static CellValue evaluateWithCycles(HSSFWorkbook wb, HSSFCell testCell)
      throws AssertionFailedError {
    HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
    try {
      return evaluator.evaluate(testCell);
    } catch (StackOverflowError e) {
      throw new AssertionFailedError( "circular reference caused stack overflow error");
    }
  }
  /**
 
View Full Code Here

            try {
            c = r.getCell(colnum);
            if (c==null || c.getCellType() != HSSFCell.CELL_TYPE_FORMULA)
                continue;
           
            HSSFFormulaEvaluator.CellValue actualValue = evaluator.evaluate(c);
           
            HSSFCell expectedValueCell = getExpectedValueCell(s, r, c);
            assertEquals("Formula: " + c.getCellFormula()
                    + " @ " + getBeginRow() + ":" + colnum,
                    expectedValueCell, actualValue);
View Full Code Here

    fe.notifyUpdateCell(cellA1);
    fe.notifyUpdateCell(cellB1);

    CellValue cv;
    cv = fe.evaluate(cellA1);
    assertEquals(3.7, cv.getNumberValue(), 0.0);

    cellB1.setCellType(HSSFCell.CELL_TYPE_BLANK);
    fe.notifyUpdateCell(cellB1);
    cv = fe.evaluate(cellA1); // B1 was used to evaluate A1
View Full Code Here

    cv = fe.evaluate(cellA1);
    assertEquals(3.7, cv.getNumberValue(), 0.0);

    cellB1.setCellType(HSSFCell.CELL_TYPE_BLANK);
    fe.notifyUpdateCell(cellB1);
    cv = fe.evaluate(cellA1); // B1 was used to evaluate A1
    assertEquals(2.2, cv.getNumberValue(), 0.0);

    cellB1.setCellValue(0.4)// changing B1, so A1 cached result should be cleared
    fe.notifyUpdateCell(cellB1);
    cv = fe.evaluate(cellA1);
View Full Code Here

    cv = fe.evaluate(cellA1); // B1 was used to evaluate A1
    assertEquals(2.2, cv.getNumberValue(), 0.0);

    cellB1.setCellValue(0.4)// changing B1, so A1 cached result should be cleared
    fe.notifyUpdateCell(cellB1);
    cv = fe.evaluate(cellA1);
    if (cv.getNumberValue() == 2.2) {
      // looks like left-over cached result from before change to B1
      throw new AssertionFailedError("Identified bug 46053");
    }
    assertEquals(2.6, cv.getNumberValue(), 0.0);
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.