Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.FormulaEvaluator.evaluate()


        // TODO Provide a way to get the one with the filename
        assertEquals("[0]!NR_Global_B2", cRefWName.getCellFormula());
       
        // Try to evaluate them
        FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
        assertEquals("Test A1", eval.evaluate(cRefSName).getStringValue());
        assertEquals(142, (int)eval.evaluate(cRefWName).getNumberValue());
       
        // Try to evaluate everything
        eval.evaluateAll();
    }
View Full Code Here


        assertEquals("[0]!NR_Global_B2", cRefWName.getCellFormula());
       
        // Try to evaluate them
        FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
        assertEquals("Test A1", eval.evaluate(cRefSName).getStringValue());
        assertEquals(142, (int)eval.evaluate(cRefWName).getNumberValue());
       
        // Try to evaluate everything
        eval.evaluateAll();
    }
View Full Code Here

          cfn.setCellFormula("A1")
          Cell cfs = r.createCell(3, Cell.CELL_TYPE_FORMULA);
          cfs.setCellFormula("B1");
         
          FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
          assertEquals(Cell.CELL_TYPE_NUMERIC, fe.evaluate(cfn).getCellType());
          assertEquals(Cell.CELL_TYPE_STRING, fe.evaluate(cfs).getCellType());
          fe.evaluateFormulaCell(cfn);
          fe.evaluateFormulaCell(cfs);
         
          // Now test
View Full Code Here

          Cell cfs = r.createCell(3, Cell.CELL_TYPE_FORMULA);
          cfs.setCellFormula("B1");
         
          FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
          assertEquals(Cell.CELL_TYPE_NUMERIC, fe.evaluate(cfn).getCellType());
          assertEquals(Cell.CELL_TYPE_STRING, fe.evaluate(cfs).getCellType());
          fe.evaluateFormulaCell(cfn);
          fe.evaluateFormulaCell(cfs);
         
          // Now test
          assertEquals(Cell.CELL_TYPE_NUMERIC, cn.getCellType());
View Full Code Here

    FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
    HSSFSheet sheet = workbook.getSheetAt(0);

    // numeric criteria
        for (int i = 0; i < 8; i++) {
      CellValue expected = evaluator.evaluate(sheet.getRow(i).getCell(REF_COL));
      CellValue actual = evaluator.evaluate(sheet.getRow(i).getCell(EVAL_COL));
      assertEquals(expected.formatAsString(), actual.formatAsString());
    }

        // boolean criteria
View Full Code Here

    HSSFSheet sheet = workbook.getSheetAt(0);

    // numeric criteria
        for (int i = 0; i < 8; i++) {
      CellValue expected = evaluator.evaluate(sheet.getRow(i).getCell(REF_COL));
      CellValue actual = evaluator.evaluate(sheet.getRow(i).getCell(EVAL_COL));
      assertEquals(expected.formatAsString(), actual.formatAsString());
    }

        // boolean criteria
        for (int i = 0; i < 8; i++) {
View Full Code Here

        for (int i = 0; i < 8; i++) {
            HSSFCell cellFmla = sheet.getRow(i).getCell(8);
            HSSFCell cellRef = sheet.getRow(i).getCell(9);

            double expectedValue = cellRef.getNumericCellValue();
            double actualValue = evaluator.evaluate(cellFmla).getNumberValue();

            assertEquals(
                    "Problem with a formula at " +
                            new CellReference(cellFmla).formatAsString() + "[" + cellFmla.getCellFormula()+"] ",
                    expectedValue, actualValue, 0.0001);
View Full Code Here

        for (int i = 1; i < 9; i++) {
            HSSFCell cellFmla = sheet.getRow(i).getCell(13);
            HSSFCell cellRef = sheet.getRow(i).getCell(14);

            double expectedValue = cellRef.getNumericCellValue();
            double actualValue = evaluator.evaluate(cellFmla).getNumberValue();

            assertEquals(
                    "Problem with a formula at " +
                            new CellReference(cellFmla).formatAsString() + "[" + cellFmla.getCellFormula()+"] ",
                    expectedValue, actualValue, 0.0001);
View Full Code Here

                             topLeft.getColumnIndex() );

                } else {
                    switch ( cell.getCellType() ) {
                        case Cell.CELL_TYPE_FORMULA:
                            CellValue cv = formulaEvaluator.evaluate( cell );
                            String cellValue = getCellValue( cv );
                            newCell( listeners,
                                     i,
                                     cellNum,
                                     cellValue,
View Full Code Here

          cfn.setCellFormula("A1")
          Cell cfs = r.createCell(3, Cell.CELL_TYPE_FORMULA);
          cfs.setCellFormula("B1");
         
          FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
          assertEquals(Cell.CELL_TYPE_NUMERIC, fe.evaluate(cfn).getCellType());
          assertEquals(Cell.CELL_TYPE_STRING, fe.evaluate(cfs).getCellType());
          fe.evaluateFormulaCell(cfn);
          fe.evaluateFormulaCell(cfs);
         
          // Now test
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.