[]
        
(Showing Draft Content)

UnParseContext

Class UnParseContext

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

public class UnParseContext extends Object
Contains options for converting a FormulaSyntaxTree to a formula string.

Use this context to control how FormulaSyntaxTree.toString(UnParseContext) formats references when converting a syntax tree back to text. The context can specify the formula position through 0-based base row and base column values, whether references are formatted in R1C1 style, and the culture used during conversion.

A new instance is empty and uses the invariant culture by default.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("OR(A1={1,3,5})");
 FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
 OperatorNode operatorNode = (OperatorNode) functionNode.getChildren().get(0);
 ArrayNode arrayNode = (ArrayNode) operatorNode.getChildren().get(1);
 Object[][] elements = arrayNode.getElements();
 elements[0][0] = 5;
 elements[0][1] = 6;
 elements[0][2] = 7;

 UnParseContext context = new UnParseContext();
 context.setIsR1C1(true);
 String formulaText = syntaxTree.toString(context);
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty UnParseContext.
  • 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
    Indicates whether the reference style is R1C1.
    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 whether formulas are converted using R1C1 reference style.

    Methods inherited from class java.lang.Object

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

    • UnParseContext

      public UnParseContext()
      Creates an empty UnParseContext.
  • Method Details

    • getBaseRow

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

      This value identifies the base row used by UnParseContext when converting a FormulaSyntaxTree back to formula text. It is typically used together with getBaseColumn() for references whose text depends on the formula location, such as R1C1-style references.

      
       UnParseContext context = new UnParseContext();
       context.setBaseRow(1);
       int baseRow = context.getBaseRow();
       
      Returns:
      The 0-based row index that represents the formula location.
    • setBaseRow

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

      This value identifies the base row used by UnParseContext when converting a FormulaSyntaxTree back to formula text. It is typically used together with getBaseColumn() for references whose text depends on the formula location, such as R1C1-style references.

      
       UnParseContext context = new UnParseContext();
       context.setBaseRow(1);
       
      Parameters:
      value - The 0-based row index that represents the formula location.
    • getBaseColumn

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

      This value is used by UnParseContext when converting a FormulaSyntaxTree to formula text, especially for references whose text depends on the formula position, such as R1C1-style references.

      
       UnParseContext context = new UnParseContext();
       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 UnParseContext when converting a FormulaSyntaxTree to formula text, especially for references whose text depends on the formula position, such as R1C1-style references.

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

      public final boolean getIsR1C1()
      Indicates whether the reference style is R1C1.
      
       UnParseContext context = new UnParseContext();
       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 whether formulas are converted using R1C1 reference style.

      Use this property when an SyntaxNode or FormulaSyntaxTree is converted to formula text through SyntaxNode.toString(UnParseContext). Set this value to true to output references in R1C1 style, or false to output references in A1 style.

      
       UnParseContext context = new UnParseContext();
       context.setIsR1C1(true);
       
      Parameters:
      value - true to use R1C1 reference style when converting formulas to text; false to use A1 reference style.