Table of Contents

Class XlsxFormula

Namespace
DocWright.Spreadsheet
Assembly
DocWright.Spreadsheet.dll

A formula read as its parts: its tokens, its tree, and every reference in it.

public sealed class XlsxFormula
Inheritance
XlsxFormula
Inherited Members

Remarks

The formula is read, not calculated. Text is the text it was parsed from, character for character, and the tokens' texts joined give it back: spacing, the case of a function's name and the way a reference is written are all kept.

The grammar is Excel's, in the A1 notation a workbook file uses, with a comma between arguments. A reference in the R1C1 notation is kept as a token of its own kind and is not resolved. A function need not be one Excel knows: _xlfn. prefixes and unknown names are kept as they are.

A formula is at most MaxLength characters, nests functions at most MaxNestingDepth levels deep and parentheses at most 256; longer or deeper text is refused, as Excel refuses it.

Fields

MaxLength

The most characters a formula has, not counting a leading equals sign: Excel's own limit.

MaxNestingDepth

The most levels of functions a function's arguments hold: Excel's own limit. Sixty-five functions inside one another parse; sixty-six do not.

Properties

References

Gets every reference in the order the text has them: cells, ranges, whole rows and columns, defined names, structured references.

Root

Gets the root of the tree.

Text

Gets the text the formula was parsed from.

Tokens

Gets the tokens in order. Their texts joined are Text.

Methods

Parse(string)

Parses a formula.

ToString()

Returns the formula's text, as it was parsed.

TryParse(string?, out XlsxFormula?)

Parses a formula, without an exception when the text is not one.