Search in sources :

Example 56 with StringEval

use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.

the class TestWorkdayFunction method testReturnNetworkdaysWithManyHolidays.

@Test
public void testReturnNetworkdaysWithManyHolidays() {
    Calendar expCal = LocaleUtil.getLocaleCalendar(2009, 4, 5);
    Date expDate = expCal.getTime();
    ValueEval[] ve = { new StringEval(STARTING_DATE), new NumberEval(151), new MockAreaEval(FIRST_HOLIDAY, SECOND_HOLIDAY, THIRD_HOLIDAY) };
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
    Date actDate = DateUtil.getJavaDate(numberValue);
    assertEquals(expDate, actDate);
}
Also used : Calendar(java.util.Calendar) StringEval(org.apache.poi.ss.formula.eval.StringEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Date(java.util.Date) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 57 with StringEval

use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.

the class TestWorkdayFunction method testReturnWorkdaysWhenStartIsWeekendAddingDays.

@Test
public void testReturnWorkdaysWhenStartIsWeekendAddingDays() {
    Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 9, 7);
    Date expDate = expCal.getTime();
    ValueEval[] ve = { new StringEval("2013/10/06"), new NumberEval(1) };
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
    assertEquals(41554.0, numberValue, 0);
    Date actDate = DateUtil.getJavaDate(numberValue);
    assertEquals(expDate, actDate);
}
Also used : Calendar(java.util.Calendar) StringEval(org.apache.poi.ss.formula.eval.StringEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Date(java.util.Date) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Example 58 with StringEval

use of org.apache.poi.ss.formula.eval.StringEval in project poi by apache.

the class TestWorkdayFunction method testReturnWorkdaysWhenStartIsWeekendSubtractingDays.

@Test
public void testReturnWorkdaysWhenStartIsWeekendSubtractingDays() {
    Calendar expCal = LocaleUtil.getLocaleCalendar(2013, 9, 4);
    Date expDate = expCal.getTime();
    ValueEval[] ve = { new StringEval("2013/10/06"), new NumberEval(-1) };
    double numberValue = ((NumberEval) WorkdayFunction.instance.evaluate(ve, EC)).getNumberValue();
    assertEquals(41551.0, numberValue, 0);
    Date actDate = DateUtil.getJavaDate(numberValue);
    assertEquals(expDate, actDate);
}
Also used : Calendar(java.util.Calendar) StringEval(org.apache.poi.ss.formula.eval.StringEval) ValueEval(org.apache.poi.ss.formula.eval.ValueEval) Date(java.util.Date) NumberEval(org.apache.poi.ss.formula.eval.NumberEval) Test(org.junit.Test)

Aggregations

StringEval (org.apache.poi.ss.formula.eval.StringEval)58 ValueEval (org.apache.poi.ss.formula.eval.ValueEval)48 NumberEval (org.apache.poi.ss.formula.eval.NumberEval)29 Test (org.junit.Test)18 AreaEval (org.apache.poi.ss.formula.eval.AreaEval)13 Calendar (java.util.Calendar)10 NumericValueEval (org.apache.poi.ss.formula.eval.NumericValueEval)10 EvaluationException (org.apache.poi.ss.formula.eval.EvaluationException)9 Date (java.util.Date)8 I_MatchPredicate (org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate)7 ErrorEval (org.apache.poi.ss.formula.eval.ErrorEval)5 BoolEval (org.apache.poi.ss.formula.eval.BoolEval)3 RefEval (org.apache.poi.ss.formula.eval.RefEval)3 BigDecimal (java.math.BigDecimal)1 DateFormatSymbols (java.text.DateFormatSymbols)1 DecimalFormat (java.text.DecimalFormat)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 NumberFormat (java.text.NumberFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1