<!-- Generated by tools/SharpCell.Docs from the XML documentation comments. Do not edit; run the tool with 'generate'. -->

# FunctionCollection

```csharp
public sealed class FunctionCollection
```

Namespace `SharpCell` · package `SharpCell`

The functions a workbook's formulas can call besides Excel's: add one with [FunctionCollection.Add](SharpCell.FunctionCollection.md#add-string-func-functionarguments-cellvalue-functionoptions), and formulas calling it by name (ignoring case) use it from the next calculation on.

## Properties

<a id="names"></a>
### Names

```csharp
public IReadOnlyCollection<string> Names { get; }
```

The names of the added functions, as they were added.

## Methods

<a id="add-string-func-functionarguments-cellvalue-functionoptions"></a>
### Add(string, Func<FunctionArguments, CellValue>, FunctionOptions)

```csharp
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](SharpCell.Workbook.md#recalculate-cancellationtoken). 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 as `WEBSERVICE`, 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](SharpCell.DiagnosticKind.md#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.

<a id="contains-string"></a>
### Contains(string)

```csharp
public bool Contains(string name)
```

Whether a function of that name was added, ignoring case.

<a id="remove-string"></a>
### Remove(string)

```csharp
public bool Remove(string name)
```

Removes a function. Formulas calling it become `#NAME?` at the next [Workbook.Recalculate](SharpCell.Workbook.md#recalculate-cancellationtoken).

**Returns:** Whether a function of that name was there.
