Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.CellValue.formatAsString()


            cellA2.setCellFormula("IF(NOT(B1=0),((ROW())),\"\")");
            CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
            System.out.println(evaluateN);
           
            assertEquals(evaluate.toString(), evaluateN.toString());
            assertEquals("2.0", evaluateN.formatAsString());
        } finally {
            wb.close();
        }
    }
   
View Full Code Here


            XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
           
            cellA2.setCellFormula("IF(NOT(B1=0),((ROW())))");
            CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
            System.out.println(evaluateN);
            assertEquals("2.0", evaluateN.formatAsString());
        } finally {
            wb.close();
        }
    }
   
View Full Code Here

            XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
           
            cellA2.setCellFormula("IF(NOT(B1=0),((ROW())),\"\")");
            CellValue evaluateN = formulaEvaluator.evaluate(cellA2);
            System.out.println(evaluateN);
            assertEquals("2.0", evaluateN.formatAsString());
        } finally {
            wb.close();
        }
    }
View Full Code Here

            XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();

            cellA2.setCellFormula("IF(B1=0,\"\",((ROW())))");
            CellValue evaluate = formulaEvaluator.evaluate(cellA2);
            System.out.println(evaluate);
            assertEquals("2.0", evaluate.formatAsString());
        } finally {
            wb.close();
        }
    }
   
View Full Code Here

            XSSFFormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();

            cellA2.setCellFormula("IF(B1=0,\"\",IF(B1=10,3,4))");
            CellValue evaluate = formulaEvaluator.evaluate(cellA2);
            System.out.println(evaluate);
            assertEquals("3.0", evaluate.formatAsString());
        } finally {
            wb.close();
        }
    }   
}
View Full Code Here

    private void confirm(String formulaText, String expectedResult) {
        cell11.setCellFormula(formulaText);
        evaluator.clearAllCachedResultValues();
        CellValue cv = evaluator.evaluate(cell11);
        if (cv.getCellType() != Cell.CELL_TYPE_STRING) {
            throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
        }
        String actualValue = cv.getStringValue();
        assertEquals(expectedResult, actualValue);
    }
}
View Full Code Here

      double expectedResult) {
    fe.clearAllCachedResultValues();
    cell.setCellFormula(formula);
    CellValue cv = fe.evaluate(cell);
    if (cv.getCellType() != Cell.CELL_TYPE_NUMERIC) {
      throw new AssertionFailedError("expected numeric cell type but got " + cv.formatAsString());
    }
    assertEquals(expectedResult, cv.getNumberValue(), 0.0);
  }
  private static void confirm(FormulaEvaluator fe, Cell cell, String formula,
      ErrorEval expectedResult) {
View Full Code Here

      ErrorEval expectedResult) {
    fe.clearAllCachedResultValues();
    cell.setCellFormula(formula);
    CellValue cv = fe.evaluate(cell);
    if (cv.getCellType() != Cell.CELL_TYPE_ERROR) {
      throw new AssertionFailedError("expected error cell type but got " + cv.formatAsString());
    }
    int expCode = expectedResult.getErrorCode();
    if (cv.getErrorValue() != expCode) {
      throw new AssertionFailedError("Expected error '" + EE.getText(expCode)
          + "' but got '" + cv.formatAsString() + "'.");
View Full Code Here

      throw new AssertionFailedError("expected error cell type but got " + cv.formatAsString());
    }
    int expCode = expectedResult.getErrorCode();
    if (cv.getErrorValue() != expCode) {
      throw new AssertionFailedError("Expected error '" + EE.getText(expCode)
          + "' but got '" + cv.formatAsString() + "'.");
    }
  }
}
View Full Code Here

    private void confirm(String formulaText, double expectedResult) {
        cell11.setCellFormula(formulaText);
        evaluator.clearAllCachedResultValues();
        CellValue cv = evaluator.evaluate(cell11);
        if (cv.getCellType() != Cell.CELL_TYPE_NUMERIC) {
            throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
        }
        double actualValue = cv.getNumberValue();
        assertEquals(expectedResult, actualValue, 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.