[]
        
(Showing Draft Content)

IName

Interface IName


public interface IName
Represents a defined name for a range of cells.

A defined name lets you assign a meaningful identifier to a cell range, formula, or constant so that it can be reused more clearly in workbook or worksheet formulas. An IName object stores the name itself together with the formula it refers to.


 IName definedName = workbook.getNames().add("SalesData", "=Sheet1!$A$1:$C$5");
 String name = definedName.getName();
 String refersTo = definedName.getRefersTo();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes this defined name.
    void
    Loads a defined name definition from the JSON string into this object.
    Gets the comment associated with the name.
    Gets the name of the object.
    Gets the formula that the name is defined to refer to, in the language of the macro and in A1-style notation, beginning with an equal sign.
    Gets the formula that the name is defined to refer to, in the language of the macro and in R1C1-style notation, beginning with an equal sign.
    boolean
    Gets whether the name is visible.
    void
    Sets the comment associated with the name.
    void
    setName(String value)
    Sets the name of the object.
    void
    Sets the formula that the name is defined to refer to, in the language of the macro and in A1-style notation, beginning with an equal sign.
    void
    Sets the formula that the name is defined to refer to, in the language of the macro and in R1C1-style notation, beginning with an equal sign.
    void
    setVisible(boolean value)
    Sets whether the name is visible.
    Generates the json string from the defined name.
  • Method Details

    • getName

      String getName()
      Gets the name of the object.

      For a defined name, this method returns the name text used to identify the referenced range, formula, or constant.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       String name = definedName.getName();
       
      Returns:
      The name of the object.
    • setName

      void setName(String value)
      Sets the name of the object.

      For a defined name, this method sets the name text used to identify the referenced range, formula, or constant.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       definedName.setName("NetSalesTotal");
       
      Parameters:
      value - The name of the object.
    • getRefersTo

      String getRefersTo()
      Gets the formula that the name is defined to refer to, in the language of the macro and in A1-style notation, beginning with an equal sign.

      Use this method to retrieve the current A1-style formula, cell reference, range reference, or constant assigned to the defined name.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       String formula = definedName.getRefersTo();
       
      Returns:
      The formula that the name refers to, in A1-style notation and beginning with an equal sign.
    • setRefersTo

      void setRefersTo(String value)
      Sets the formula that the name is defined to refer to, in the language of the macro and in A1-style notation, beginning with an equal sign.

      Use this method to set the current A1-style formula, cell reference, range reference, or constant assigned to the defined name.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       definedName.setRefersTo("=SUM(A1:A3)");
       
      Parameters:
      value - The formula that the name refers to, in A1-style notation and beginning with an equal sign.
    • getRefersToR1C1

      String getRefersToR1C1()
      Gets the formula that the name is defined to refer to, in the language of the macro and in R1C1-style notation, beginning with an equal sign.

      Use this method to read the defined name formula in R1C1-style notation. To work with the A1-style equivalent, use getRefersTo().

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       definedName.setRefersToR1C1("=R1C1:R3C1");
       String refersToR1C1 = definedName.getRefersToR1C1();
       
      Returns:
      The formula that the name refers to, in R1C1-style notation, beginning with an equal sign.
    • setRefersToR1C1

      void setRefersToR1C1(String value)
      Sets the formula that the name is defined to refer to, in the language of the macro and in R1C1-style notation, beginning with an equal sign.

      Use this method to set the defined name formula in R1C1-style notation. To work with the A1-style equivalent, use getRefersTo().

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       definedName.setRefersToR1C1("=SUM(R1C1:R3C1)");
       
      Parameters:
      value - The formula that the name refers to, in R1C1-style notation, beginning with an equal sign.
    • getComment

      String getComment()
      Gets the comment associated with the name.

      Use this method to retrieve the descriptive text assigned to a defined name.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       definedName.setComment("Total sales range");
       String comment = definedName.getComment();
       
      Returns:
      The comment associated with the name.
    • setComment

      void setComment(String value)
      Sets the comment associated with the name.

      Use this method to set the descriptive text assigned to a defined name.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       definedName.setComment("Total sales range");
       
      Parameters:
      value - The comment associated with the name.
    • getVisible

      boolean getVisible()
      Gets whether the name is visible.
      
       IName definedName = workbook.getNames().add("SalesTotal", "=Sheet1!$A$1:$A$3");
       definedName.setVisible(false);
       boolean visible = definedName.getVisible();
       
      Returns:
      true if the name is visible.
    • setVisible

      void setVisible(boolean value)
      Sets whether the name is visible.
      
       IName definedName = workbook.getNames().add("SalesTotal", "=Sheet1!$A$1:$A$3");
       definedName.setVisible(false);
       boolean visible = definedName.getVisible();
       
      Parameters:
      value - true to make the name visible; otherwise, false.
    • delete

      void delete()
      Deletes this defined name.

      Use this method to remove a workbook-level or worksheet-level name that is represented by this IName object.

      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       definedName.delete();
       
    • fromJson

      void fromJson(String json)
      Loads a defined name definition from the JSON string into this object.

      Use this method to apply a defined name definition from a JSON string, such as one generated by toJson().

      
       IName name = workbook.getNames().add("SalesTotal", "=SUM(A1:A3)");
       name.setComment("Quarter total");
       String json = name.toJson();
       name.fromJson(json);
       
      Parameters:
      json - The JSON string that contains a defined name.
    • toJson

      String toJson()
      Generates the json string from the defined name.
      
       worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
       IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
       String json = definedName.toJson();
       
      Returns:
      The json string.