[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Expressions.SyntaxNode.Parse

Parse Method

Parse(string)

Loads a SyntaxNode from a string that contains a formula.

This method calls Parse(string, ParseContext) with the default parse context.

If text is null or empty, this method returns Instance.

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

A string that contains the formula to parse. This value can be null or empty.

Returns
Type Description
SyntaxNode

A SyntaxNode populated from the specified formula text. Returns Instance if text is null or empty.

Examples
SyntaxNode node = SyntaxNode.Parse("SUM(A1:A3)+B1");
string formulaText = node.ToString();
Exceptions
Type Condition
ArgumentException

if text contains invalid formula syntax.

Parse(string, ParseContext)

Loads a SyntaxNode from a formula string using the specified ParseContext.

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

If text is null or empty, this method returns the singleton empty node. If the formula text is invalid, this method throws an ArgumentException.

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

The formula text to parse. If null or empty, this method returns an empty node.

ParseContext context

The parse context that specifies the base row, base column, and whether the formula uses R1C1 reference style.

Returns
Type Description
SyntaxNode

A SyntaxNode populated from the specified formula text, or the empty node if text is null or empty.

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

SyntaxNode node = SyntaxNode.Parse("R1C:R8C[4]*9", context);
string formula = node.ToString();
Exceptions
Type Condition
ArgumentException

if text is not a valid formula.