Search in sources :

Example 21 with CellType

use of org.apache.poi.ss.usermodel.CellType in project poi by apache.

the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_BlankCompareToZero.

@Test
public void testIFEqualsFormulaEvaluation_BlankCompareToZero() {
    final String formula = "IF(A1=0, B1, C1)";
    final CellType cellType = CellType.BLANK;
    final String expectedFormula = "IF(A1=0,B1,C1)";
    final double expectedValue = 2.0;
    testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
Also used : CellType(org.apache.poi.ss.usermodel.CellType) Test(org.junit.Test)

Example 22 with CellType

use of org.apache.poi.ss.usermodel.CellType in project poi by apache.

the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_Boolean.

@Ignore("Bug 58591: this test currently fails")
@Test
public void testIFEqualsFormulaEvaluation_Boolean() {
    final String formula = "IF(A1=1, B1, C1)";
    final CellType cellType = CellType.BOOLEAN;
    final String expectedFormula = "IF(A1=1,B1,C1)";
    final double expectedValue = 2.0;
    testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
Also used : CellType(org.apache.poi.ss.usermodel.CellType) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with CellType

use of org.apache.poi.ss.usermodel.CellType in project poi by apache.

the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_StringCoerceToNumeric.

@Test
public void testIFEqualsFormulaEvaluation_StringCoerceToNumeric() {
    final String formula = "IF(A1+0=1, B1, C1)";
    final CellType cellType = CellType.STRING;
    final String expectedFormula = "IF(A1+0=1,B1,C1)";
    final double expectedValue = 2.0;
    testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
Also used : CellType(org.apache.poi.ss.usermodel.CellType) Test(org.junit.Test)

Example 24 with CellType

use of org.apache.poi.ss.usermodel.CellType in project poi by apache.

the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_NumericLiteral.

@Test
public void testIFEqualsFormulaEvaluation_NumericLiteral() {
    final String formula = "IF(A1=1, 2, 3)";
    final CellType cellType = CellType.NUMERIC;
    final String expectedFormula = "IF(A1=1,2,3)";
    final double expectedValue = 2.0;
    testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
Also used : CellType(org.apache.poi.ss.usermodel.CellType) Test(org.junit.Test)

Example 25 with CellType

use of org.apache.poi.ss.usermodel.CellType in project poi by apache.

the class TestWorkbookEvaluator method testIFEqualsFormulaEvaluation_BlankInverted.

@Ignore("Bug 58591: this test currently fails")
@Test
public void testIFEqualsFormulaEvaluation_BlankInverted() {
    final String formula = "IF(NOT(A1)=1, B1, C1)";
    final CellType cellType = CellType.BLANK;
    final String expectedFormula = "IF(NOT(A1)=1,B1,C1)";
    final double expectedValue = 2.0;
    testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
}
Also used : CellType(org.apache.poi.ss.usermodel.CellType) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CellType (org.apache.poi.ss.usermodel.CellType)32 Test (org.junit.Test)17 STCellType (org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType)7 RichTextString (org.apache.poi.ss.usermodel.RichTextString)5 Cell (org.apache.poi.ss.usermodel.Cell)4 CellValue (org.apache.poi.ss.usermodel.CellValue)4 Row (org.apache.poi.ss.usermodel.Row)4 Ignore (org.junit.Ignore)4 CellStyle (org.apache.poi.ss.usermodel.CellStyle)3 HSSFCell (org.apache.poi.hssf.usermodel.HSSFCell)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 XSSFRichTextString (org.apache.poi.xssf.usermodel.XSSFRichTextString)2 CTCellFormula (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula)2 AttributedString (java.text.AttributedString)1 AssertionFailedError (junit.framework.AssertionFailedError)1 HSSFFormulaEvaluator (org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator)1 HSSFRow (org.apache.poi.hssf.usermodel.HSSFRow)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 CellReference (org.apache.poi.hssf.util.CellReference)1 Font (org.apache.poi.ss.usermodel.Font)1