| Modifier | Constructor and Description |
|---|---|
protected |
Row(Sheet parent,
int rowIndex)
Creates a new instance of row.
|
| Modifier and Type | Method and Description |
|---|---|
Cell |
addCell(Object value)
Creates a new cell at the end of this row and sets to it given value.
|
Cell |
createCell(int colIndex)
Creates a new cell at the given column index and returns its representing object.
|
Cell |
getCell(int colIndex)
Gets the cell of this row represented by given column index.
|
Cell |
getCell(String cellRef)
Gets the cell of this row represented by given reference.
|
SpreadsheetDocument |
getDocument()
Gets parent Spreadsheet document.
|
int |
getFirstCellIndex()
Gets index of the first defined cell on this row.
|
com.google.api.services.sheets.v4.model.RowData |
getGRow()
Returns underlay Google API object representing this row.
|
int |
getIndex()
Gets index of this row.
|
int |
getLastCellIndex()
Gets index of the last cell of this row.
|
List<Object> |
getRange(int startCol,
int endCol)
Gets values of cells range on this row.
|
<T> List<T> |
getRange(int startCol,
int endCol,
Class<T> valueType)
Gets values of cells range on this row and converts them to the type specified by
valueType. |
List<Object> |
getRange(String startRef,
String endRef)
Gets values of cells range of this row.
|
<T> List<T> |
getRange(String startRef,
String endRef,
Class<T> valueType)
Gets values of cells range on this row and converts them to the type specified by
valueType. |
CellRef |
getReference()
Gets reference to this row.
|
Sheet |
getSheet()
Gets parent sheet.
|
Object |
getValue(int colIndex)
Gets the value of this row cell by given column index.
|
<T> T |
getValue(int colIndex,
Class<T> valueType)
Gets the value of this row cell by given column index.
|
Object |
getValue(String cellRef)
Gets the value of this row cell by given cell reference.
|
<T> T |
getValue(String cellRef,
Class<T> valueType)
Gets the value of this row cell by given cell reference and converts it to the type
specified by
valueType. |
List<Object> |
getValues()
Gets values of all row cells.
|
<T> List<T> |
getValues(Class<T> valueType)
Gets values of all row cells.
|
Iterator<Cell> |
iterator()
Returns an iterator of objects representing existing cells of this row.
|
void |
putRange(int startCol,
List<?> values)
Sets given values to cells range of this row which starts from cell with column index defined by
startCol. |
void |
putRange(String startRef,
List<?> values)
Sets given values to cells range of this row which starts from cell defined by
startRef. |
void |
setValue(int colIndex,
Object value)
Sets the value of this row cell by given column index.
|
void |
setValue(String cellRef,
Object value)
Sets the value of this row cell by given cell reference.
|
void |
setValues(List<?> values)
Sets given values to cells range of this row which starts from cell with column index 0.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected Row(Sheet parent, int rowIndex)
parent - reference to parent sheet.rowIndex - 0-based index of this row.public SpreadsheetDocument getDocument()
public Sheet getSheet()
public int getIndex()
public CellRef getReference()
Row reference is a reference to its cell with column index 0.
CellRefpublic Object getValue(String cellRef)
cellRef - reference string to necessary cell. E.g. "A23".null if nothing is found. The actual class of value
is depend on cell type. Can be returned Double, Boolean, LocalDateTime or String.public <T> T getValue(String cellRef, 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 values to corresponding type or null if the conversion
fails.
For other types it performs simple type casting of cell values to T or throws ClassCastException
if such type casting is not possible.
T - type of returning value. Defined by value of valueType.cellRef - reference string to necessary cell. E.g. "A23".valueType - class instance of returning value.null if nothing is found. The class of return
value is defined by 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 Object getValue(int colIndex)
colIndex - 0-based column index of the cell.null if nothing is found. The actual class of value
is depend on cell type. Can be returned Double, Boolean, LocalDateTime or String.public <T> T getValue(int colIndex,
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 values to corresponding type or null if the conversion
fails.
For other types it performs simple type casting of cell values to T or throws ClassCastException
if such type casting is not possible.
T - type of returning value. Defined by value of valueType.colIndex - 0-based column index of the cell.valueType - class instance of returning value.null if nothing is found. The class of return
value is defined by 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(String cellRef, Object value)
cellRef - reference string to necessary cell. E.g. "A23".value - the value to set.public void setValue(int colIndex,
Object value)
colIndex - 0-based column index of the cell.value - the value to set.public List<Object> getValues()
It's an equivalent to getting of range between first and last cells of this row.
Double, Boolean, LocalDateTime or String.getRange(int, int, Class),
getFirstCellIndex(),
getLastCellIndex()public <T> List<T> getValues(Class<T> valueType)
Returning values are automatically converted to the type specified by valueType.
It's an equivalent to getting of range between first and last cells of this row.
T - type of returning values. Defined by value of valueType.valueType - class instance of returning values.valueType. If the actual class of cell values is different from
valueType the automatic conversion will be applied.getRange(int, int, Class),
getFirstCellIndex(),
getLastCellIndex()public void setValues(List<?> values)
The end cell of the range is defined by size of given values.
It's an equivalent to putRange(0, values).
values - list of values to set.putRange(int, List)public List<Object> getRange(String startRef, String endRef)
startRef - reference string to the start cell of the range. Only column part is taken into consideration.
E.g. "A23".endRef - reference string to the end cell of the range. Only column part is taken into consideration.
E.g. "D23".Double, Boolean, LocalDateTime or
String.getRange(int, int, Class)public <T> List<T> getRange(String startRef, String endRef, Class<T> valueType)
valueType.
The range is defined by given start and end cell references.
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 values to corresponding type or null if the conversion
fails.
For other types it performs simple type casting of cell values to T or throws ClassCastException
if such type casting is not possible.
T - type of returning cell values. Defined by value of valueType.startRef - reference string to the start cell of the range. Only column part is taken into consideration.
E.g. "A23".endRef - reference string to the end cell of the range. Only column part is taken into consideration.
E.g. "D23".valueType - class instance of returning cell values.valueType. If the actual class of cell values 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 List<Object> getRange(int startCol, int endCol)
startCol - 0-based index of left column of the range.endCol - 0-based index of right column of the range.Double, Boolean, LocalDateTime or String.public <T> List<T> getRange(int startCol, int endCol, Class<T> valueType)
valueType.
The range is defined by given left and right column indexes.
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 values to corresponding type or null if the conversion
fails.
For other types it performs simple type casting of cell values to T or throws ClassCastException
if such type casting is not possible.
T - type of returning cell values. Defined by value of valueType.startCol - 0-based index of left column of the range.endCol - 0-based index of right column of the range.valueType - class instance of returning cell values.valueType. If the actual class of cell values 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 putRange(String startRef, List<?> values)
startRef.
The end cell of the range is defined by size of given values.
startRef - reference string to the start cell of the range. E.g. "A23".values - list of values to set.public void putRange(int startCol,
List<?> values)
startCol.
The end cell of the range is defined by size of given values.
startCol - 0-based column index of the start cell of the range.values - list of values to set.public Cell getCell(String cellRef)
cellRef - reference string to necessary cell. Only column part is taken into consideration. E.g. "A23".null if cell is not defined.public Cell getCell(int colIndex)
colIndex - 0-based column index of necessary cell.null if cell is not defined.public Cell createCell(int colIndex)
colIndex - 0-based column index where cell should be created.public Cell addCell(Object value)
value - the cell value to set.public int getFirstCellIndex()
Cell is defined if underlying POI object is not null.
-1 if no cells exist.public int getLastCellIndex()
-1 if no cells exist.public Iterator<Cell> iterator()
This method allows using of this row object in "for" loop:
for(Cell cell: row){
int colIndex = cell.getColumnIndex();
...
}
public com.google.api.services.sheets.v4.model.RowData getGRow()
Copyright © 2022. All rights reserved.