[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Expressions.FormulaSyntaxTree.Parse

Parse Method

Parse(string)

Creates a new FormulaSyntaxTree from a formula string.

The specified text should contain only the formula expression. It should not start with = and should not be surrounded with {= }. If text is null or empty, this method returns an empty FormulaSyntaxTree.

Use Parse(string, ParseContext) when the formula needs parsing options such as base row, base column, or R1C1 reference style.

Declaration
public static FormulaSyntaxTree Parse(string text)
Public Shared Function Parse(text As String) As FormulaSyntaxTree
Parameters
Type Name Description
string text

The formula text to parse. This value can be null or empty.

Returns
Type Description
FormulaSyntaxTree

A FormulaSyntaxTree populated from the specified formula text, or an empty FormulaSyntaxTree if text is null or empty.

Examples
string formula = "SUM(A1:A3)+B1";
FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse(formula);
SyntaxNode root = syntaxTree.Root;

Parse(string, ParseContext)

Parses formula text into a FormulaSyntaxTree by using the specified ParseContext.

Use the parse context to control how references in the formula text are interpreted, including the zero-based base row, zero-based base column, and whether the formula uses R1C1 reference style.

If text is null or empty, this method returns an empty FormulaSyntaxTree whose root node is null.

Declaration
public static FormulaSyntaxTree Parse(string text, ParseContext context)
Public Shared Function Parse(text As String, context As ParseContext) As FormulaSyntaxTree
Parameters
Type Name Description
string text

The formula text to parse. If text is null or empty, an empty FormulaSyntaxTree is returned.

ParseContext context

The parse context that specifies the base row, base column, and reference style used to interpret the formula text.

Returns
Type Description
FormulaSyntaxTree

A FormulaSyntaxTree created from the specified formula text. Returns an empty FormulaSyntaxTree if text is null or empty.

Examples
ParseContext context = new ParseContext();
context.BaseRow = 1;
context.BaseColumn = 4;
context.IsR1C1 = true;

FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("R1C:R3C[1]", context);
SyntaxNode root = syntaxTree.Root;