[]
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();
voiddelete()voidgetName()booleanvoidsetComment(String value) voidvoidsetRefersTo(String value) voidsetRefersToR1C1(String value) voidsetVisible(boolean value) toJson()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();
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");
value - The name of the object.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();
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)");
value - The formula that the name refers to, in A1-style notation and 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();
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)");
value - The formula that the name refers to, in R1C1-style notation, beginning with an equal sign.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();
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");
value - The comment associated with the name.
IName definedName = workbook.getNames().add("SalesTotal", "=Sheet1!$A$1:$A$3");
definedName.setVisible(false);
boolean visible = definedName.getVisible();
true if the name is visible.
IName definedName = workbook.getNames().add("SalesTotal", "=Sheet1!$A$1:$A$3");
definedName.setVisible(false);
boolean visible = definedName.getVisible();
value - true to make the name visible; otherwise, false.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();
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);
json - The JSON string that contains a defined name.
worksheet.getRange("A1:A3").setValue(new Object[][] {{100}, {200}, {300}});
IName definedName = worksheet.getNames().add("SalesTotal", "=A1:A3");
String json = definedName.toJson();