Skip to content

Class SourceCodeTokenizer

Namespace: OfficeOpenXml.FormulaParsing.LexicalAnalysis
Assembly: EPPlus.dll

Source code tokenizer

public class SourceCodeTokenizer : ISourceCodeTokenizer

Inheritance

object ← SourceCodeTokenizer

Implements

ISourceCodeTokenizer

Inherited Members

object.Equals(object?, object?)
object.Equals(object?)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object?, object?)
object.ToString()

Constructors

SourceCodeTokenizer(IFunctionNameProvider, INameValueProvider, bool, bool, bool)

public SourceCodeTokenizer(IFunctionNameProvider functionRepository, INameValueProvider nameValueProvider, bool r1c1 = false, bool keepWhitespace = false, bool pivotFormula = false)

Parameters

functionRepository IFunctionNameProvider

A function name provider

nameValueProvider INameValueProvider

A name value provider

r1c1 bool

If true the tokenizer will use the R1C1 format

keepWhitespace bool

If true whitspaces in formulas will be preserved

pivotFormula bool

If the formula is from a calculated column in a pivot table.

Properties

Default

The default tokenizer. This tokenizer will remove and ignore whitespaces.

public static ISourceCodeTokenizer Default { get; }

Property Value

ISourceCodeTokenizer

Default_KeepWhiteSpaces

The default tokenizer. This tokenizer will remove and ignore whitespaces.

public static ISourceCodeTokenizer Default_KeepWhiteSpaces { get; }

Property Value

ISourceCodeTokenizer

PivotFormula

public static ISourceCodeTokenizer PivotFormula { get; }

Property Value

ISourceCodeTokenizer

R1C1

The tokenizer used for r1c1 format. This tokenizer will keep whitespaces and add them as tokens.

public static ISourceCodeTokenizer R1C1 { get; }

Property Value

ISourceCodeTokenizer

Methods

Tokenize(string)

Split the input string into tokens used by the formula parser

public IList<Token> Tokenize(string input)

Parameters

input string

Returns

IList<Token>

Tokenize(string, string)

Splits a formula in tokens used in when calculating for example a worksheet cell, defined name or a pivot table field formula.

public IList<Token> Tokenize(string input, string worksheet)

Parameters

input string

The formula to tokenize

worksheet string

The worksheet name.

Returns

IList<Token>

Exceptions

InvalidFormulaException

Thrown if the formula is not valid.