Modifier and Type | Method and Description |
---|---|
String |
getComment()
Returns the comment the user provided when the name was created.
|
String |
getNameName()
Gets the name of the named range
|
String |
getReference()
Deprecated.
(Nov 2008) Misleading name. Use
getRefersToFormula() instead. |
String |
getRefersToFormula()
Returns the formula that the name is defined to refer to.
|
int |
getSheetIndex()
Returns the sheet index this name applies to.
|
String |
getSheetName()
Get the sheets name which this named range is referenced to
|
boolean |
isBuiltInName() |
boolean |
isDeleted()
Checks if this name points to a cell that no longer exists
|
boolean |
isFunctionName()
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 |
setNameName(String nameName)
Sets the name of the named range
|
void |
setReference(String ref)
Deprecated.
(Nov 2008) Misleading name. Use
setRefersToFormula(String) instead. |
void |
setRefersToFormula(String formulaText)
Sets the formula that the name is defined to refer to.
|
void |
setSheetIndex(int index)
Specifies if the defined name is a local name, and if so, which sheet it is on.
|
String |
toString() |
public String getSheetName()
getSheetName
in interface Name
public String getNameName()
Name
getNameName
in interface Name
public void setNameName(String nameName)
The following is a list of syntax rules that you need to be aware of when you create and edit names.
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 HSSFName 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)"
setNameName
in interface Name
nameName
- named range name to setIllegalArgumentException
- if the name is invalid or the name already exists (case-insensitive)public String getReference()
getRefersToFormula()
instead.public void setReference(String ref)
setRefersToFormula(String)
instead.public void setRefersToFormula(String formulaText)
Name
'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)
setRefersToFormula
in interface Name
formulaText
- the reference for this namepublic String getRefersToFormula()
Name
getRefersToFormula
in interface Name
null
if it has not been set yet. Never empty stringName.setRefersToFormula(String)
public boolean isDeleted()
Name
public boolean isFunctionName()
isFunctionName
in interface Name
public void setSheetIndex(int index)
setSheetIndex
in interface Name
index
- if greater than 0, the defined name is a local name and the value MUST be a 0-based index
to the collection of sheets as they appear in the workbook.IllegalArgumentException
- if the sheet index is invalid.public int getSheetIndex()
getSheetIndex
in interface Name
public String getComment()
getComment
in interface Name
public void setComment(String comment)
setComment
in interface Name
comment
- the user comment for this named rangepublic void setFunction(boolean value)
setFunction
in interface Name
value
- true
indicates the name refers to a function.public boolean isBuiltInName()
Copyright © 2020. All rights reserved.