[]
IName objects that store defined names.Each IName object represents a defined name for a cell, cell range, formula, or constant. Names can be either built-in names, such as Database, Print_Area, and Auto_Open, or custom names created in workbook or worksheet scope.
INames names = workbook.getNames();
names.add("SalesData", "A1:B3");
IName salesData = names.get("SalesData");
voidclear()IName collection.booleanINames.voidget(int index) IName object from a collection.IName object from a collection.intgetCount()toJson()For an INames collection, the objects are defined names.
INames names = workbook.getNames();
names.add("SalesRange", "=Sheet1!$A$1:$A$5");
int count = names.getCount();
IName object.Uses A1-style notation in refersTo to define what the name refers to, such as a cell, range, formula, or constant.
INames names = worksheet.getNames();
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"Test", 100},
{"Total", 200}
});
IName salesData = names.add("SalesData", "A1:B3");
name - The text to use as the name. Names cannot include spaces and cannot look like cell references.refersTo - The A1-style reference string that describes what the name refers to.IName object.INames. Use this method to check whether the collection already includes a defined name before retrieving it with get(String) or adding a new one.
INames names = workbook.getNames();
names.add("SalesRange", "=Sheet1!$A$1:$A$5");
boolean contains = names.contains("SalesRange");
name - The name to look for in the collection.true if INames contains the specified name; otherwise, false.IName object from a collection.Use this method to retrieve a defined name by its name.
INames names = workbook.getNames();
names.add("SalesRange", "=Sheet1!$A$1:$A$5");
IName name = names.get("SalesRange");
name - Specifies the name of an element in the collection.IName object from the collection.IName object from a collection.Use the zero-based index of the defined name in this collection to retrieve a specific name object.
INames names = workbook.getNames();
names.add("SalesRange", "=Sheet1!$A$1:$A$5");
IName name = names.get(0);
String definedName = name.getName();
index - Specifies the index of an element in the collection.IName object at the specified index in the collection.IName collection.Removes all defined names from this collection, including names in the current workbook or worksheet scope represented by this INames instance.
worksheet.getRange("A1").setValue("North");
INames names = worksheet.getNames();
names.add("RegionName", "=Sheet1!$A$1");
names.clear();
Use this method to import defined names into the collection from JSON data, such as data previously generated by toJson().
INames names = workbook.getNames();
names.add("SalesRange", "=Sheet1!$A$1:$A$5");
String json = names.toJson();
names.clear();
names.fromJson(json);
json - The JSON string that contains defined names.The returned string serializes the current collection of defined names and can be used with fromJson(String) to restore the collection later.
INames names = workbook.getNames();
names.add("SalesRange", "=Sheet1!$A$1:$A$5");
String json = names.toJson();