Search in sources :

Example 36 with HSSFFormulaEvaluator

use of org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator in project poi by apache.

the class TestAddress method testAddress.

public void testAddress() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFCell cell = wb.createSheet().createRow(0).createCell(0);
    HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
    String formulaText = "ADDRESS(1,2)";
    confirmResult(fe, cell, formulaText, "$B$1");
    // with explicitly empty third parameter
    formulaText = "ADDRESS(1,2,)";
    confirmResult(fe, cell, formulaText, "$B$1");
    formulaText = "ADDRESS(22,44)";
    confirmResult(fe, cell, formulaText, "$AR$22");
    formulaText = "ADDRESS(1,1)";
    confirmResult(fe, cell, formulaText, "$A$1");
    formulaText = "ADDRESS(1,128)";
    confirmResult(fe, cell, formulaText, "$DX$1");
    formulaText = "ADDRESS(1,512)";
    confirmResult(fe, cell, formulaText, "$SR$1");
    formulaText = "ADDRESS(1,1000)";
    confirmResult(fe, cell, formulaText, "$ALL$1");
    formulaText = "ADDRESS(1,10000)";
    confirmResult(fe, cell, formulaText, "$NTP$1");
    formulaText = "ADDRESS(2,3)";
    confirmResult(fe, cell, formulaText, "$C$2");
    formulaText = "ADDRESS(2,3,2)";
    confirmResult(fe, cell, formulaText, "C$2");
    formulaText = "ADDRESS(2,3,2,,\"EXCEL SHEET\")";
    confirmResult(fe, cell, formulaText, "'EXCEL SHEET'!C$2");
    formulaText = "ADDRESS(2,3,3,TRUE,\"[Book1]Sheet1\")";
    confirmResult(fe, cell, formulaText, "'[Book1]Sheet1'!$C2");
}
Also used : HSSFFormulaEvaluator(org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Example 37 with HSSFFormulaEvaluator

use of org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator in project poi by apache.

the class TestCalendarFieldFunction method setUp.

@Override
public void setUp() {
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");
    cell11 = sheet.createRow(0).createCell(0);
    cell11.setCellType(CellType.FORMULA);
    evaluator = new HSSFFormulaEvaluator(wb);
}
Also used : HSSFFormulaEvaluator(org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator) HSSFSheet(org.apache.poi.hssf.usermodel.HSSFSheet) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Aggregations

HSSFFormulaEvaluator (org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator)37 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)34 HSSFCell (org.apache.poi.hssf.usermodel.HSSFCell)29 HSSFSheet (org.apache.poi.hssf.usermodel.HSSFSheet)26 HSSFRow (org.apache.poi.hssf.usermodel.HSSFRow)15 CellValue (org.apache.poi.ss.usermodel.CellValue)10 AssertionFailedError (junit.framework.AssertionFailedError)9 Test (org.junit.Test)9 Row (org.apache.poi.ss.usermodel.Row)2 CellReference (org.apache.poi.ss.util.CellReference)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 EmptyStackException (java.util.EmptyStackException)1 HSSFDataFormat (org.apache.poi.hssf.usermodel.HSSFDataFormat)1 HSSFDataFormatter (org.apache.poi.hssf.usermodel.HSSFDataFormatter)1 CellReference (org.apache.poi.hssf.util.CellReference)1 FormulaParseException (org.apache.poi.ss.formula.FormulaParseException)1 AggregatingUDFFinder (org.apache.poi.ss.formula.udf.AggregatingUDFFinder)1 DefaultUDFFinder (org.apache.poi.ss.formula.udf.DefaultUDFFinder)1 UDFFinder (org.apache.poi.ss.formula.udf.UDFFinder)1