org.apache.poi.hssf.usermodel
Class HSSFName

java.lang.Object
  extended by org.apache.poi.hssf.usermodel.HSSFName
All Implemented Interfaces:
Name

public final class HSSFName
extends java.lang.Object
implements Name

High Level Representation of a 'defined name' which could be a 'built-in' name, 'named range' or name of a user defined function.

Author:
Libin Roman (Vista Portal LDT. Developer)

Method Summary
 java.lang.String getComment()
          Returns the comment the user provided when the name was created.
 java.lang.String getNameName()
          Gets the name of the named range
 java.lang.String getReference()
          Deprecated. (Nov 2008) Misleading name. Use getRefersToFormula() instead.
 java.lang.String getRefersToFormula()
          Returns the formula that the name is defined to refer to.
 int getSheetIndex()
          Returns the sheet index this name applies to.
 java.lang.String getSheetName()
          Get the sheets name which this named range is referenced to
 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(java.lang.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(java.lang.String nameName)
          Sets the name of the named range
 void setReference(java.lang.String ref)
          Deprecated. (Nov 2008) Misleading name. Use setRefersToFormula(String) instead.
 void setRefersToFormula(java.lang.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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getSheetName

public java.lang.String getSheetName()
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

getNameName

public java.lang.String getNameName()
Description copied from interface: Name
Gets the name of the named range

Specified by:
getNameName in interface Name
Returns:
text name of this defined name

setNameName

public void setNameName(java.lang.String nameName)
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.

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)"

Specified by:
setNameName in interface Name
Parameters:
nameName - named range name to set
Throws:
java.lang.IllegalArgumentException - if the name is invalid or the name already exists (case-insensitive)

getReference

public java.lang.String getReference()
Deprecated. (Nov 2008) Misleading name. Use getRefersToFormula() instead.

Returns the formula that the name is defined to refer to.


setReference

public void setReference(java.lang.String ref)
Deprecated. (Nov 2008) Misleading name. Use setRefersToFormula(String) instead.

Sets the formula that the name is defined to refer to.


setRefersToFormula

public void setRefersToFormula(java.lang.String formulaText)
Description copied from interface: Name
Sets the formula that the name is defined to refer to. The following are representative examples:

Specified by:
setRefersToFormula in interface Name
Parameters:
formulaText - the reference for this name

getRefersToFormula

public java.lang.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:
Name.setRefersToFormula(String)

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

isFunctionName

public boolean isFunctionName()
Checks if this name is a function name

Specified by:
isFunctionName in interface Name
Returns:
true if this name is a function name

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setSheetIndex

public void setSheetIndex(int index)
Specifies if the defined name is a local name, and if so, which sheet it is on.

Specified by:
setSheetIndex in interface Name
Parameters:
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.
Throws:
java.lang.IllegalArgumentException - if the sheet index is invalid.

getSheetIndex

public int getSheetIndex()
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

getComment

public java.lang.String getComment()
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(java.lang.String comment)
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)
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.


Copyright 2012 The Apache Software Foundation or its licensors, as applicable.