Package org.apache.poi.ss.util
Class CellAddress
- java.lang.Object
-
- org.apache.poi.ss.util.CellAddress
-
- All Implemented Interfaces:
java.lang.Comparable<CellAddress>
public class CellAddress extends java.lang.Object implements java.lang.Comparable<CellAddress>
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
CellReferencewhen 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
Fields Modifier and Type Field Description static CellAddressA1A constant for references to the first cell in a sheet.
-
Constructor Summary
Constructors Constructor Description CellAddress(int row, int column)Create a new CellAddress object.CellAddress(java.lang.String address)Create a new CellAddress object.CellAddress(Cell cell)Create a new CellAddress object.CellAddress(CellAddress address)Create a new CellAddress objectCellAddress(CellReference reference)Create a new CellAddress object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(CellAddress other)Compare this CellAddress using the "natural" row-major, column-minor ordering.booleanequals(java.lang.Object o)java.lang.StringformatAsString()Same astoString()intgetColumn()Get the cell address columnintgetRow()Get the cell address rowinthashCode()java.lang.StringtoString()
-
-
-
Field Detail
-
A1
public static final CellAddress A1
A constant for references to the first cell in a sheet.
-
-
Constructor Detail
-
CellAddress
public CellAddress(int row, int column)Create a new CellAddress object.- Parameters:
row- Row index (first row is 0)column- Column index (first column is 0)
-
CellAddress
public CellAddress(java.lang.String address)
Create a new CellAddress object.- Parameters:
address- a cell address in A1 format. Address may not contain sheet name or dollar signs. (that is, address is not a cell reference. UseCellAddress(CellReference)instead if starting with a cell reference.)
-
CellAddress
public CellAddress(CellReference reference)
Create a new CellAddress object.- Parameters:
reference- a reference to a cell
-
CellAddress
public CellAddress(CellAddress address)
Create a new CellAddress object- Parameters:
address- a CellAddress
-
CellAddress
public CellAddress(Cell cell)
Create a new CellAddress object.- Parameters:
cell- the Cell to get the location of
-
-
Method Detail
-
getRow
public int getRow()
Get the cell address row- Returns:
- row
-
getColumn
public int getColumn()
Get the cell address column- Returns:
- column
-
compareTo
public int compareTo(CellAddress other)
Compare this CellAddress using the "natural" row-major, column-minor ordering. That is, top-left to bottom-right ordering.- Specified by:
compareToin interfacejava.lang.Comparable<CellAddress>- Parameters:
other-- 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
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
formatAsString
public java.lang.String formatAsString()
Same astoString()- Returns:
- A1-style cell address string representation
-
-