public class Cell extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
Cell(Sheet parent,
int rowIndex,
int columnIndex)
Creates a new instance of cell.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
int |
getColumnIndex()
Gets column index of this cell.
|
SpreadsheetDocument |
getDocument()
Gets parent Spreadsheet document.
|
String |
getFormula()
Gets string with specified for this cell formula.
|
com.google.api.services.sheets.v4.model.CellData |
getGCell()
Returns underlay Google API object representing this cell.
|
CellRange |
getMergedRegion()
Gets merged region where this cell is hit.
|
Cell |
getMergedRegionCell()
Gets top-left cell of merged region where this cell is hit.
|
CellRef |
getReference()
Gets reference to this cell.
|
int |
getRowIndex()
Gets row index of this cell.
|
Sheet |
getSheet()
Gets parent sheet.
|
CellStyle |
getStyle()
Gets current style of this cell.
|
Object |
getValue()
Gets the value of this cell.
|
<T> T |
getValue(Class<T> valueType)
Gets the value of this cell and converts it to the type specified by
valueType. |
boolean |
hasFormula()
Checks whether formula is specified for this cell.
|
int |
hashCode() |
boolean |
isEmpty()
Checks whether this cell is empty.
|
boolean |
isMerged()
Checks whether this cell is merged with other neighbour cells.
|
void |
setFormula(String newCellFormula)
Sets formula for this cell.
|
void |
setStyle(CellStyle newStyle)
Sets and applies specific style for this cell.
|
void |
setValue(Object value)
Sets the value for this cell.
|
protected Cell(Sheet parent, int rowIndex, int columnIndex)
parent - reference to parent sheet.rowIndex - 0-based row index of the cell.columnIndex - 0-based column index of the cell.public SpreadsheetDocument getDocument()
public Sheet getSheet()
public int getRowIndex()
public int getColumnIndex()
public CellRef getReference()
CellRefpublic CellStyle getStyle()
CellStylepublic void setStyle(CellStyle newStyle)
newStyle - the cell style to apply.CellStylepublic Object getValue()
Double, Boolean, LocalDateTime or String.public <T> T getValue(Class<T> valueType)
valueType.
If valueType is String.class, Byte.class, Short.class,
Integer.class, Long.class, Float.class or Double.class
this method performs automatic conversion of cell value to corresponding type or return null if
the conversion fails.
For other types it performs simple type casting of cell value to T or throws ClassCastException
if such type casting is not possible.
T - type of return value. Defined by value of valueType.valueType - class instance of return value.valueType. If the actual class
of cell value is different from valueType the automatic conversion will be applied.ClassCastException - if T is different from String or Number and the value of cell cannot be
cast to T.public void setValue(Object value)
value - the value to set.public boolean isEmpty()
true if this cell is not defined, blank or has empty value. Returns false otherwise.public boolean hasFormula()
true if the formula is specified for this cell or false otherwise.public String getFormula()
null if cell does not have formula.public void setFormula(String newCellFormula)
newCellFormula - string with formula to set.public boolean isMerged()
true if this cell is merged with other neighbour cells or false otherwise.public CellRange getMergedRegion()
null if this cell is not merged with
other cells.CellRangepublic Cell getMergedRegionCell()
null if this cell is
not merged with other cells.public com.google.api.services.sheets.v4.model.CellData getGCell()
Copyright © 2022. All rights reserved.