Пример #1
0
        /**
         * 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);
            }
        }
Пример #2
0
        /**
         * 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);
        }