I am willing to take stab at implementing this. I think I can do the properties file part on my own based on what you've provided below. In this case, I assume it will search for a specific file name? Or should it be something like a -D argument passed in? Or maybe both? (a default file name and property to override it?)
The error message for unknown functions sounds a little more involved, can you give me some ideas of where to look to understand the intricacies? Jon ----- Original Message ---- From: Yegor Kozlov <[email protected]> To: [email protected] Sent: Tue, October 5, 2010 7:02:19 AM Subject: Re: how to add functions to POI > As far as patching it, I don't think it *needs* a patch. One suggestion might > be that when POI encounters a custom function and it throws an exception, the > comments of the exception point users to the UDFFinder docs. > This sounds like a good idea. If the formula evaluator stumbles on an unknown function then the exception should suggest a workaround with UDF. There can be tricky details - we need to tell unknown defined names from unknown functions, this detection should work transparently for .xls and .xlsx formats, etc. But anyway, I like the idea. Your idea with configuration of UDFs also makes sense but I don't want to make it too complicated. POI does not depend on Spring and I don't think we will add a new dependency just for configuration of UDFs. So, Java properties is the way to go. In current implementation if UDFFinder is not specified then a default instance is used, see UDFFinder.java: public static final UDFFinder DEFAULT = new AggregatingUDFFinder(AnalysisToolPak.instance); I think it should be re-written into something like this public static final UDFFinder DEFAULT = new AggregatingUDFFinder.getInstance(); where getInstance() will search for a configuration file (system property or classpath) and programmatically register UDFs, just like in the test case. This way future versions of POI will be compatible with existing user code. If support for custom VBA functions is needed then all user needs to do is to implement the VBA code as FreeRefFunction and register it in the configuration file. Yegor --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
