Class ExternalLinksTable.ExternalName

java.lang.Object
org.apache.poi.xssf.model.ExternalLinksTable.ExternalName
All Implemented Interfaces:
Name
Enclosing class:
ExternalLinksTable

protected class ExternalLinksTable.ExternalName extends Object implements Name
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ExternalName(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalDefinedName name)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the comment the user provided when the name was created.
    Gets the name of the named range
    Returns the formula that the name is defined to refer to.
    int
    Returns the sheet index this name applies to.
    Get the sheets name which this named range is referenced to
    boolean
    Checks if this name points to a cell that no longer exists
    boolean
    Checks if this name is a function name
    void
    setComment(String comment)
    Sets the comment the user provided when the name was created.
    void
    setFunction(boolean value)
    Indicates that the defined name refers to a user-defined function.
    void
    Sets the name of the named range
    void
    Sets the formula that the name is defined to refer to.
    void
    setSheetIndex(int sheetId)
    Tell Excel that this name applies to the worksheet with the specified index instead of the entire workbook.

    Methods inherited from class java.lang.Object

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

    • ExternalName

      protected ExternalName(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalDefinedName name)
  • Method Details

    • getNameName

      public String getNameName()
      Description copied from interface: Name
      Gets the name of the named range
      Specified by:
      getNameName in interface Name
      Returns:
      named range name
    • setNameName

      public void setNameName(String name)
      Description copied from interface: Name
      Sets the name of the named range

      The following is a list of syntax rules that you need to be aware of when you create and edit names.

      • Valid characters The first character of a name must be a letter, an underscore character (_), or a backslash (\). Remaining characters in the name can be letters, numbers, periods, and underscore characters.
      • Cell references disallowed Names cannot be the same as a cell reference, such as Z$100 or R1C1.
      • Spaces are not valid Spaces are not allowed as part of a name. Use the underscore character (_) and period (.) as word separators, such as, Sales_Tax or First.Quarter.
      • Name length A name can contain up to 255 characters.
      • Case sensitivity Names can contain uppercase and lowercase letters.

      A name must always be unique within its scope. POI prevents you from defining a name that is not unique within its scope. However you can use the same name in different scopes. Example:

      //by default names are workbook-global Name name; name = workbook.createName(); name.setNameName("sales_08"); name = workbook.createName(); name.setNameName("sales_08"); //will throw an exception: "The workbook already contains this name (case-insensitive)" //create sheet-level name name = workbook.createName(); name.setSheetIndex(0); //the scope of the name is the first sheet name.setNameName("sales_08"); //ok name = workbook.createName(); name.setSheetIndex(0); name.setNameName("sales_08"); //will throw an exception: "The sheet already contains this name (case-insensitive)"

      Specified by:
      setNameName in interface Name
      Parameters:
      name - named range name to set
    • getSheetName

      public String getSheetName()
      Description copied from interface: Name
      Get the sheets name which this named range is referenced to
      Specified by:
      getSheetName in interface Name
      Returns:
      sheet name, which this named range referred to
    • getSheetIndex

      public int getSheetIndex()
      Description copied from interface: Name
      Returns the sheet index this name applies to.
      Specified by:
      getSheetIndex in interface Name
      Returns:
      the sheet index this name applies to, -1 if this name applies to the entire workbook
    • setSheetIndex

      public void setSheetIndex(int sheetId)
      Description copied from interface: Name
      Tell Excel that this name applies to the worksheet with the specified index instead of the entire workbook.
      Specified by:
      setSheetIndex in interface Name
      Parameters:
      sheetId - the sheet index this name applies to, -1 unsets this property making the name workbook-global
    • getRefersToFormula

      public String getRefersToFormula()
      Description copied from interface: Name
      Returns the formula that the name is defined to refer to.
      Specified by:
      getRefersToFormula in interface Name
      Returns:
      the reference for this name, null if it has not been set yet. Never empty string
      See Also:
    • setRefersToFormula

      public void setRefersToFormula(String formulaText)
      Description copied from interface: Name
      Sets the formula that the name is defined to refer to. The following are representative examples:
      • 'My Sheet'!$A$3
      • 8.3
      • HR!$A$1:$Z$345
      • SUM(Sheet1!A1,Sheet2!B2)
      • -PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)
      Note: Using relative values like 'A1:B1' can lead to unexpected moving of the cell that the name points to when working with the workbook in Microsoft Excel, usually using absolute references like '$A$1:$B$1' avoids this, see also https://superuser.com/a/1031047/126954
      Specified by:
      setRefersToFormula in interface Name
      Parameters:
      formulaText - the reference for this name
    • isFunctionName

      public boolean isFunctionName()
      Description copied from interface: Name
      Checks if this name is a function name
      Specified by:
      isFunctionName in interface Name
      Returns:
      true if this name is a function name
    • isDeleted

      public boolean isDeleted()
      Description copied from interface: Name
      Checks if this name points to a cell that no longer exists
      Specified by:
      isDeleted in interface Name
      Returns:
      true if the name refers to a deleted cell, false otherwise
    • getComment

      public String getComment()
      Description copied from interface: Name
      Returns the comment the user provided when the name was created.
      Specified by:
      getComment in interface Name
      Returns:
      the user comment for this named range
    • setComment

      public void setComment(String comment)
      Description copied from interface: Name
      Sets the comment the user provided when the name was created.
      Specified by:
      setComment in interface Name
      Parameters:
      comment - the user comment for this named range
    • setFunction

      public void setFunction(boolean value)
      Description copied from interface: Name
      Indicates that the defined name refers to a user-defined function. This attribute is used when there is an add-in or other code project associated with the file.
      Specified by:
      setFunction in interface Name
      Parameters:
      value - true indicates the name refers to a function.