FunctionCollection
public sealed class FunctionCollection
Namespace SharpCell · package SharpCell
The functions a workbook's formulas can call besides Excel's: add one with FunctionCollection.Add, and formulas calling it by name (ignoring case) use it from the next calculation on.
Properties
Names
public IReadOnlyCollection<string> Names { get; }
The names of the added functions, as they were added.
Methods
Add(string, Func<FunctionArguments, CellValue>, FunctionOptions)
public void Add(string name, Func<FunctionArguments, CellValue> body, FunctionOptions? options = null)
Adds a function. Formulas that call the name, and were #NAME? so far, are calculated again by the next Workbook.Recalculate. Calls written _xll.NAME(...) or _xludf.NAME(...), as Excel stores calls of add-in functions in files, find it too.
Parameters
name: Letters, digits,.and_, starting with a letter or_; not the name of a function SharpCell implements. A name Excel knows but SharpCell does not implement, such asWEBSERVICE, is allowed.body: Calculates the result from the arguments. It must not change the workbook, and it should read cells only through its arguments: cells it reads otherwise are not dependencies, so it is not calculated again when they change. An exception it throws makes the cell#VALUE!with a DiagnosticKind.CustomFunctionFailure diagnostic.options: Argument counts, which parameters are scalar, and whether the function is volatile; null for any number of arguments passed as they are.
Exceptions
ArgumentException: The name is not a function name, is built in, or was added already; or the options are not consistent.
Contains(string)
public bool Contains(string name)
Whether a function of that name was added, ignoring case.
Remove(string)
public bool Remove(string name)
Removes a function. Formulas calling it become #NAME? at the next Workbook.Recalculate.
Returns: Whether a function of that name was there.