| Modifier | Constructor and Description |
|---|---|
protected |
Column(Sheet parent,
int columnIndex)
Creates a new instance of column.
|
| Modifier and Type | Method and Description |
|---|---|
Cell |
createCell(int rowIndex)
Creates a new cell at the given row index and returns its representing object.
|
Cell |
getCell(int rowIndex)
Gets the cell of this column represented by given row index.
|
Cell |
getCell(String cellRef)
Gets the cell of this column represented by given reference.
|
SpreadsheetDocument |
getDocument()
Gets parent Spreadsheet document.
|
int |
getFirstRowIndex()
Gets row index of the first defined cell at this column.
|
int |
getIndex()
Gets index of this column.
|
int |
getLastRowIndex()
Gets row index of the last cell of this column.
|
List<Object> |
getRange(int startRow,
int endRow)
Gets values of cells range on this column.
|
<T> List<T> |
getRange(int startRow,
int endRow,
Class<T> valueType)
Gets values of cells range on this column and converts them to the type specified by
valueType. |
List<Object> |
getRange(String startRef,
String endRef)
Gets values of cells range of this column.
|
<T> List<T> |
getRange(String startRef,
String endRef,
Class<T> valueType)
Gets values of cells range on this column and converts them to the type specified by
valueType. |
CellRef |
getReference()
Gets reference to this column.
|
Sheet |
getSheet()
Gets parent sheet.
|
Object |
getValue(int rowIndex)
Gets the value of this column cell by given row index.
|
<T> T |
getValue(int rowIndex,
Class<T> valueType)
Gets the value of this column cell by given row index.
|
Object |
getValue(String cellRef)
Gets the value of this column cell by given cell reference.
|
<T> T |
getValue(String cellRef,
Class<T> valueType)
Gets the value of this column cell by given cell reference and converts it to the type
specified by
valueType. |
List<Object> |
getValues()
Gets values of all column cells.
|
<T> List<T> |
getValues(Class<T> valueType)
Gets values of all column cells.
|
boolean |
isEmpty()
Checks whether this column is empty.
|
Iterator<Cell> |
iterator()
Returns an iterator of objects representing existing cells of this column.
|
void |
putRange(int startRow,
List<?> values)
Sets given values to cells range of this column which starts from cell with row index defined by
startRow. |
void |
putRange(String startRef,
List<?> values)
Sets given values to cells range of this column which starts from cell defined by
startRef. |
void |
setValue(int rowIndex,
Object value)
Sets the value of this column cell by given row index.
|
void |
setValue(String cellRef,
Object value)
Sets the value of this column cell by given cell reference.
|
void |
setValues(List<?> values)
Sets given values to cells range of this column which starts from cell with row index 0.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprotected Column(Sheet parent, int columnIndex)
parent - reference to parent sheet.columnIndex - 0-based index of this column.public SpreadsheetDocument getDocument()
public Sheet getSheet()
public int getIndex()
public CellRef getReference()
Column reference is a reference to its cell with row 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 rowIndex)
rowIndex - 0-based row 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 rowIndex,
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.rowIndex - 0-based row 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 rowIndex,
Object value)
rowIndex - 0-based row 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 column.
Double, Boolean, LocalDateTime or String.getRange(int, int, Class),
getFirstRowIndex(),
getLastRowIndex()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 column.
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),
getFirstRowIndex(),
getLastRowIndex()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 row part is taken into consideration.
E.g. "A5".endRef - reference string to the end cell of the range. Only row part is taken into consideration.
E.g. "A23".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 row part is taken into consideration.
E.g. "A5".endRef - reference string to the end cell of the range. Only row part is taken into consideration.
E.g. "A23".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 startRow, int endRow)
startRow - 0-based index of top row of the range.endRow - 0-based index of bottom row of the range.Double, Boolean, LocalDateTime or String.public <T> List<T> getRange(int startRow, int endRow, Class<T> valueType)
valueType.
The range is defined by given top and bottom row 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.startRow - 0-based index of top row of the range.endRow - 0-based index of bottom row 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 startRow,
List<?> values)
startRow.
The end cell of the range is defined by size of given values.
startRow - 0-based row 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 row part is taken into consideration. E.g. "A23".null if cell is not defined.public Cell getCell(int rowIndex)
rowIndex - 0-based row index of necessary cell.null if cell is not defined.public Cell createCell(int rowIndex)
rowIndex - 0-based row index where cell should be created.public int getFirstRowIndex()
Cell is defined if underlying Google CellData object is not null.
-1 if no cells
exist (column is empty).public int getLastRowIndex()
-1 if no cells
exist (column is empty).public boolean isEmpty()
true if all cells of this column are not defined, blank or has empty values.
Returns false otherwise.Copyright © 2022. All rights reserved.