[]
        
(Showing Draft Content)

ParseContext

Class ParseContext

java.lang.Object
com.grapecity.documents.excel.expressions.ParseContext

public class ParseContext extends Object
Represents options used when converting formula text to a FormulaSyntaxTree.

Use this class to supply parsing context for FormulaSyntaxTree.Parse(String,ParseContext), such as the formula location and whether references are interpreted in R1C1 style. The base row and base column are zero-based indexes.


 ParseContext context = new ParseContext();
 context.setBaseRow(0);
 context.setBaseColumn(0);
 context.setIsR1C1(false);
 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("a\\b", context);
 SyntaxNode root = syntaxTree.getRoot();
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty parse context.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    Gets the 0-based column location of the formula.
    final int
    Gets the 0-based row location of the formula.
    final boolean
    Gets a value indicating whether references are interpreted in R1C1 style.
    final void
    setBaseColumn(int value)
    Sets the 0-based column location of the formula.
    final void
    setBaseRow(int value)
    Sets the 0-based row location of the formula.
    final void
    setIsR1C1(boolean value)
    Sets a value indicating whether references are interpreted in R1C1 style.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ParseContext

      public ParseContext()
      Creates an empty parse context.
  • Method Details

    • getBaseRow

      public final int getBaseRow()
      Gets the 0-based row location of the formula.

      This value identifies the formula's base row in the parse context and is used together with getBaseColumn() when parsing formulas whose references depend on their location, such as R1C1-style references. Use setBaseRow(int) to specify this value before calling FormulaSyntaxTree.Parse(String,ParseContext).

      
       ParseContext context = new ParseContext();
       context.setBaseRow(1);
       int baseRow = context.getBaseRow();
       
      Returns:
      The 0-based row location of the formula.
    • setBaseRow

      public final void setBaseRow(int value)
      Sets the 0-based row location of the formula.
      
       ParseContext context = new ParseContext();
       context.setBaseRow(1);
       
      Parameters:
      value - The 0-based row location of the formula.
    • getBaseColumn

      public final int getBaseColumn()
      Gets the 0-based column location of the formula.

      This value is used by ParseContext when parsing formulas that depend on the formula's position, such as relative references.

      
       ParseContext context = new ParseContext();
       context.setBaseColumn(7);
       int baseColumn = context.getBaseColumn();
       
      Returns:
      The 0-based column index that represents the formula location.
    • setBaseColumn

      public final void setBaseColumn(int value)
      Sets the 0-based column location of the formula.

      This value is used by ParseContext when parsing formulas that depend on the formula's position, such as relative references.

      
       ParseContext context = new ParseContext();
       context.setBaseColumn(7);
       
      Parameters:
      value - The 0-based column index that represents the formula location.
    • getIsR1C1

      public final boolean getIsR1C1()
      Gets a value indicating whether references are interpreted in R1C1 style.

      Use this property together with getBaseRow() and getBaseColumn() when the parse context is used for FormulaSyntaxTree.Parse(String,ParseContext). If this method returns true, formula references are parsed as R1C1-style references; otherwise, A1-style references are used.

      
       ParseContext context = new ParseContext();
       context.setBaseRow(1);
       context.setBaseColumn(4);
       context.setIsR1C1(true);
       boolean isR1C1 = context.getIsR1C1();
       
      Returns:
      true if the reference style is R1C1; otherwise, false.
    • setIsR1C1

      public final void setIsR1C1(boolean value)
      Sets a value indicating whether references are interpreted in R1C1 style.

      Use this property together with getBaseRow() and getBaseColumn() when the parse context is used for FormulaSyntaxTree.Parse(String,ParseContext). If this method is set to true, formula references are parsed as R1C1-style references; otherwise, A1-style references are used.

      
       ParseContext context = new ParseContext();
       context.setBaseRow(1);
       context.setBaseColumn(4);
       context.setIsR1C1(true);
       
      Parameters:
      value - true if the reference style is R1C1; otherwise, false.