You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Detlef Brendle <de...@canoo.com> on 2013/01/23 21:46:13 UTC
Question: Why does POI not provide a Function for EDATE ?
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
<http://www.canoo.com/>
Detlef Brendle
Canoo Engineering AG
Kirschgartenstrasse 5
CH-4051 Basel
Tel: +41 61 228 94 44
Fax: +41 61 228 94 49
detlef.brendle@canoo.com <ma...@canoo.com>
http://www.canoo.com
Re: Question: Why does POI not provide a Function for EDATE ?
Posted by Nick Burch <ni...@apache.org>.
On 23/01/13 20:46, Detlef Brendle wrote:
> 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.
POI is a volunteer project. People contribute code to the areas that
matter to them. It looks like you're the first person to use EDATE who's
also able and willing to contribute! :)
> 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)
Great, thanks! You'll probably want to read through
http://poi.apache.org/spreadsheet/eval-devguide.html and
http://people.apache.org/~yegor/apachecon_us2010/Evaluation_Of_Excel_Formulas_In_POI.pptx
, then please create a new bug in bugzilla with your patch
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org