/** * Register a ATP function in runtime. * * @param name the function name * @param func the functoin to register * @throws ArgumentException if the function is unknown or already registered. * @since 3.8 beta6 */ public static void RegisterFunction(String name, FreeRefFunction func) { AnalysisToolPak inst = (AnalysisToolPak)instance; if (!IsATPFunction(name)) { FunctionMetadata metaData = FunctionMetadataRegistry.GetFunctionByName(name); if (metaData != null) { throw new ArgumentException(name + " is a built-in Excel function. " + "Use FunctoinEval.RegisterFunction(String name, Function func) instead."); } else { throw new ArgumentException(name + " is not a function from the Excel Analysis Toolpack."); } } FreeRefFunction f = inst.FindFunction(name); if (f != null && !(f is NotImplemented)) { throw new ArgumentException("POI already implememts " + name + ". You cannot override POI's implementations of Excel functions"); } if (_functionsByName.ContainsKey(name)) { _functionsByName[name] = func; } else { _functionsByName.Add(name, func); } }
/** * Returns a collection of ATP function names NOT implemented by POI. * * @return an array of not supported functions * @since 3.8 beta6 */ public static ReadOnlyCollection <String> GetNotSupportedFunctionNames() { AnalysisToolPak inst = (AnalysisToolPak)instance; List <String> lst = new List <String>(); foreach (String name in AnalysisToolPak._functionsByName.Keys) { FreeRefFunction func = (FreeRefFunction)AnalysisToolPak._functionsByName[(name)]; if (func != null && (func is NotImplemented)) { lst.Add(name); } } return(lst.AsReadOnly()); //Collections.unmodifiableCollection(lst); }
/** * Returns a collection of ATP function names implemented by POI. * * @return an array of supported functions * @since 3.8 beta6 */ public static ReadOnlyCollection <String> GetSupportedFunctionNames() { AnalysisToolPak inst = (AnalysisToolPak)instance; List <String> lst = new List <String>(); foreach (KeyValuePair <String, FreeRefFunction> me in AnalysisToolPak._functionsByName) { FreeRefFunction func = me.Value; if (func != null && !(func is NotImplemented)) { lst.Add(me.Key); } } return(lst.AsReadOnly()); //Collections.unmodifiableCollection(lst); }