Top Description Fields Constructors Methods
org.apache.poi.ss.util

public Class CellAddress

extends Object
implements Comparable<CellAddress>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.util.Locale, org.apache.poi.ss.usermodel.Cell

This class is a container for POI usermodel row=0 column=0 cell references. It is barely a container for these two coordinates. The implementation of the Comparable interface sorts by "natural" order top left to bottom right.

Use CellAddress when you want to refer to the location of a cell in a sheet when the concept of relative/absolute does not apply (such as the anchor location of a cell comment). Use CellReference when the concept of relative/absolute does apply (such as a cell reference in a formula). CellAddresses do not have a concept of "sheet", while CellReferences do.

Field Summary

Modifier and TypeField and Description
private final int
private final int
public static final CellAddress
A1

A constant for references to the first cell in a sheet.

Constructor Summary

AccessConstructor and Description
public
CellAddress(int
Row index (first row is 0)
row
,
int
Column index (first column is 0)
column
)

Create a new CellAddress object.

public
CellAddress(String
a cell address in A1 format. Address may not contain sheet name or dollar signs. (that is, address is not a cell reference. Use CellAddress(CellReference) instead if starting with a cell reference.)
address
)

Create a new CellAddress object.

public
CellAddress(CellReference
a reference to a cell
reference
)

Create a new CellAddress object.

public
CellAddress(CellAddress
a CellAddress
address
)

Create a new CellAddress object

public
CellAddress(Cell
the Cell to get the location of
cell
)

Create a new CellAddress object.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

  • -1 if this CellAddress is before (above/left) of other
  • 0 if addresses are the same
  • 1 if this CellAddress is after (below/right) of other
compareTo
(CellAddress
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compare this CellAddress using the "natural" row-major, column-minor ordering.

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String

Returns:

R1C1-style cell address string representation
formatAsR1C1String
()

public String

Returns:

A1-style cell address string representation
formatAsString
()

Same as toString()

public int

Returns:

column
getColumn
()

Get the cell address column

public int

Returns:

row
getRow
()

Get the cell address row

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_colback to summary
private final int _col
_rowback to summary
private final int _row
A1back to summary
public static final CellAddress A1

A constant for references to the first cell in a sheet.

Constructor Detail

CellAddressback to summary
public CellAddress(int row, int column)

Create a new CellAddress object.

Parameters
row:int

Row index (first row is 0)

column:int

Column index (first column is 0)

CellAddressback to summary
public CellAddress(String address)

Create a new CellAddress object.

Parameters
address:String

a cell address in A1 format. Address may not contain sheet name or dollar signs. (that is, address is not a cell reference. Use CellAddress(CellReference) instead if starting with a cell reference.)

CellAddressback to summary
public CellAddress(CellReference reference)

Create a new CellAddress object.

Parameters
reference:CellReference

a reference to a cell

CellAddressback to summary
public CellAddress(CellAddress address)

Create a new CellAddress object

Parameters
address:CellAddress

a CellAddress

CellAddressback to summary
public CellAddress(Cell cell)

Create a new CellAddress object.

Parameters
cell:Cell

the Cell to get the location of

Method Detail

compareToback to summary
public int compareTo(CellAddress other)

Implements java.lang.Comparable.compareTo.

Compare this CellAddress using the "natural" row-major, column-minor ordering. That is, top-left to bottom-right ordering.

Parameters
other:CellAddress

Doc from java.lang.Comparable.compareTo.

the object to be compared.

Returns:int

  • -1 if this CellAddress is before (above/left) of other
  • 0 if addresses are the same
  • 1 if this CellAddress is after (below/right) of other
Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
formatAsR1C1Stringback to summary
public String formatAsR1C1String()
Returns:String

R1C1-style cell address string representation

Since
POI 5.2.1
See Also
formatAsString()
formatAsStringback to summary
public String formatAsString()

Same as toString()

Returns:String

A1-style cell address string representation

getColumnback to summary
public int getColumn()

Get the cell address column

Returns:int

column

getRowback to summary
public int getRow()

Get the cell address row

Returns:int

row

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override