Hi,
I started using POI 3.9 recently and was missing an implementation for the EDATE Excel Function
(http://office.microsoft.com/en-us/excel-help/edate-function-HP010342465.aspx)

I looked at it and implemented it by myself. Here is a groovy implementation which looks very simple:
It looks so simple, as I doubt nobody ever added that function to POI.

So is there a special Reason why it is not implemented in POI yet ?

If there is no special reason I would be more that happy to share my implmentation with the POI team.
(I can also create a JAVA implmentation out of it and provide tests for it)

Regards,
detlef

**************************
import org.apache.poi.ss.formula.OperationEvaluationContext
import org.apache.poi.ss.formula.eval.NumberEval
import org.apache.poi.ss.formula.eval.ValueEval
import org.apache.poi.ss.formula.functions.FreeRefFunction
import org.apache.poi.ss.usermodel.DateUtil

class EDateFunction implements FreeRefFunction {
    ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
        def startValue = args[0].getInnerValueEval().numberValue
        Date startDate = DateUtil.getJavaDate(startValue)
        def calendar = Calendar.getInstance()
        calendar.time = startDate
        calendar.add(Calendar.MONTH, args[1].numberValue as int)
        return new NumberEval(DateUtil.getExcelDate(calendar.time))
    }
}

***************************
--
Canoo
              Engineering AG - your provider for business web solutions
Detlef Brendle
Canoo Engineering AG
Kirschgartenstrasse 5
CH-4051 Basel
Tel:  +41 61 228 94 44
Fax: +41 61 228 94 49

Reply via email to