poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pantelis Sopasakis <ch...@mail.ntua.gr>
Subject Re: How to register a newly implemented function that is not supported in POI?
Date Thu, 26 Apr 2012 10:47:21 GMT
Hi Christian, All,
  
  I have successfully implemented/overridden a few functions with POI that output a **single
value** and I'll try to explain how to do it. At the same time, I am trying to implement the
function MINVERSE which admits areas of data and returns also areas. So far I am able to read
the input as an object of type AreaEval but I'm still having a hard time returning the output
properly. Yegol Kozlov mentioned in a previous email that I should return an object of type
AreaEval as well but I haven't found out how to construct it properly. So if anyone can help...
I would appreciate it.

You can find my version of MINVERSE here:  http://pastebin.com/5WfrkjBw and my main class
here: http://pastebin.com/TdHBVS1T. Also take a look at this: http://pastebin.com/L4gxebFH
(Abstract Excel Function).

As you can see in the source code (follow the links above), I register the newly implemented
function to the evaluator as follows 

FunctionEval.registerFunction("MINVERSE", new Minverse());

The above line works perfectly and in fact following the same steps as I did you can implement
any function of yours.

Your function must implement the class org.apache.poi.ss.formula.functions.Function.

You can take a look at http://pastebin.com/L4gxebFH - you may consider subclassing my AbstractExcelFunction
that offers a few functionalities.


Best regards,
Pantelis Sopasakis




> Hello to all,
> 
>  
> 
> this is just to understand how to "register" a newly implemented function that is not
supported in POI.
> 
>  
> 
> As the pages of POI say on the developer guide ("Walkthrough of an evaluate() implementatio",
http://poi.apache.org/spreadsheet/eval-devguide.html), you should create a new Function, say
SQRTPI, write the code for evaluate() and then register it to the WorkbookEvaluator:
> 
>  
> 
> WorkbookEvaluator.registerFunction("SQRTPI", SQRTPI);
> 
>  
> 
> I copied the example of SQRTPI into my code and tried to register this function, but
this does not work. 
> 
>  
> 
> This seems to be because the method registerFunction() is not existent in class WorkbookEvaluator,
though the Javadocs still show this method. 
> 
>  
> 
> Can someone help and perhaps just show what to do to implement one of the not-implemented
functions in POI? 
> 
>  
> 
> Thx, 
> 
> Christian


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message