[]
        
(Showing Draft Content)

NameNode

Class NameNode


public class NameNode extends TerminalNode
Represents a name node in the syntax tree.

A NameNode stores the short name together with optional worksheet scope information and an optional WorkbookReference for external workbook references. Use this class to represent parsed names such as a workbook-scoped or worksheet-scoped name in a formula expression tree.


 FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("MonthName");
 NameNode nameNode = (NameNode) syntaxTree.getRoot();
 String name = nameNode.getName();
 
  • Constructor Details

    • NameNode

      public NameNode(String name)
      Creates a new NameNode from the specified string.

      This constructor forwards null for the workbook, start worksheet, and end worksheet information.

      Parameters:
      name - The short name.
    • NameNode

      public NameNode(String name, String worksheetName, String lastWorksheetName)
      Creates a new NameNode from a range of sheets.

      This constructor forwards null as the workbook reference to NameNode(String,WorkbookReference,String,String).

      Parameters:
      name - The short name.
      worksheetName - The name of start worksheet.
      lastWorksheetName - The name of end worksheet.
    • NameNode

      public NameNode(String name, WorkbookReference workbook, String worksheetName, String lastWorksheetName)
      Creates a new NameNode from a range of sheets of the specified workbook.

      Use this constructor to represent a defined name in a formula syntax tree when the name belongs to an external workbook and is qualified by a worksheet range.

      Parameters:
      name - The short name.
      workbook - The external workbook reference.
      worksheetName - The name of start worksheet.
      lastWorksheetName - The name of end worksheet.
  • Method Details

    • getWorkbook

      public final WorkbookReference getWorkbook()
      Gets the external workbook reference.

      Returns the WorkbookReference associated with this NameNode when the name is qualified by an external workbook.

      
       NameNode nameNode = new NameNode(
           "SalesTotal",
           WorkbookReference.FromName("Budget.xlsx"),
           "Sheet1",
           null
       );
       WorkbookReference workbookReference = nameNode.getWorkbook();
       
      Returns:
      The external workbook reference, or null if this name does not refer to an external workbook.
    • setWorkbook

      public final void setWorkbook(WorkbookReference value)
      Sets the external workbook reference.

      Use this method to associate the name with an external workbook when the NameNode represents a workbook-qualified name in a formula syntax tree. Pass null to remove the current external workbook reference.

      
       NameNode nameNode = new NameNode("SalesTotal", "Sheet1", "Sheet3");
       WorkbookReference workbookRef = WorkbookReference.FromName("BuildingSales");
       nameNode.setWorkbook(workbookRef);
       
      Parameters:
      value - The external workbook reference to assign, or null to clear it.
    • getWorksheetName

      public final String getWorksheetName()
      Gets the worksheet of the name.

      Returns the starting worksheet name stored in this NameNode. Use this method to retrieve the worksheet scope of the name when the name is qualified by a worksheet or worksheet range.

      
       NameNode nameNode = new NameNode("SalesTotal", "Sheet1", "Sheet3");
       String worksheetName = nameNode.getWorksheetName();
       
      Returns:
      The starting worksheet name of the name, or null if no worksheet scope has been set.
    • setWorksheetName

      public final void setWorksheetName(String value)
      Sets the worksheet of the name.

      sets the starting worksheet name stored in this NameNode. Use this method to update the worksheet scope of the name when the name is qualified by a worksheet or worksheet range.

      
       NameNode nameNode = new NameNode("SalesTotal", "Sheet1", "Sheet3");
       nameNode.setWorksheetName("Sheet2");
       
      Parameters:
      value - The starting worksheet name of the name, or null if no worksheet scope has been set.
    • getLastWorksheetName

      public final String getLastWorksheetName()
      Gets the name of the last worksheet in the range.

      Use this method to retrieve the ending worksheet name when this NameNode represents a name scoped to a range of worksheets.

      
       NameNode nameNode = new NameNode("SalesTotal", "Sheet1", "Sheet3");
       String lastWorksheetName = nameNode.getLastWorksheetName();
       
      Returns:
      The name of the last worksheet in the range.
    • setLastWorksheetName

      public final void setLastWorksheetName(String value)
      Sets the name of the last worksheet in the range.

      Use this method to set the ending worksheet name when this NameNode represents a name scoped to a range of worksheets.

      
       NameNode nameNode = new NameNode("SalesTotal", "Sheet1", "Sheet3");
       nameNode.setLastWorksheetName("Sheet4");
       
      Parameters:
      value - The name of the last worksheet in the range.
    • getName

      public final String getName()
      Gets the short name.

      Returns the short name stored in this NameNode.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("MonthName");
       NameNode nameNode = (NameNode) syntaxTree.getRoot();
       String name = nameNode.getName();
       
      Returns:
      The short name, or null if no short name has been set.
    • setName

      public final void setName(String value)
      Sets the short name.

      sets the short name stored in this NameNode.

      
       FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("MonthName");
       NameNode nameNode = (NameNode) syntaxTree.getRoot();
       nameNode.setName("NetSales");
       String formulaText = syntaxTree.toString();
       
      Parameters:
      value - The short name, or null if no short name has been set.