Table of Contents

Class XlsxFormula

Namespace
DocToolkit
Assembly
DocToolkit.dll

A cell value meaning "this cell holds a formula". Use it anywhere a cell value is accepted — inside XlsxSheet rows, inside rows passed to AppendRows(byte[], string, IEnumerable<IEnumerable<object?>>), or as the value argument to SetCell(byte[], string, string, object?).

No cached result is written. The file carries the formula and nothing else. Excel recalculates when it opens the file, and this package's own readers (ReadCell(byte[], string, string), ReadSheet(byte[], string)) compute the value on read — but a third-party reader that only reads cached values, such as openpyxl with data_only=True, sees an empty cell until Excel has opened and saved the file.

A formula that cannot be evaluated reads back as its Excel error string — #DIV/0!, #NAME?, #REF! — rather than throwing, which is what Excel itself shows.

public sealed class XlsxFormula
Inheritance
XlsxFormula
Inherited Members

Properties

Formula

The formula, without a leading =, which is how the file stores it.

public string Formula { get; }

Property Value

string

Methods

From(string)

Creates a formula cell value. A leading = is optional and is stripped: the file format stores formulas without it, and accepting both spellings stops the value that round-trips from differing from the one that was written.

public static XlsxFormula From(string formula)

Parameters

formula string

Returns

XlsxFormula

Exceptions

ArgumentNullException

formula is null.

ArgumentException

formula is empty, whitespace, or just "=".