columnByKey method
Fetches column by its name.
Expands current sheet's size if requested range is out of sheet's bounds.
key
- name of a requested column
The first row considered to be column names
fromRow
- optional (defaults to 2), index of a row that requested column
starts from (values before fromRow
will be skipped),
rows start at index 1
length
- optional (defaults to -1), the length of a requested column
if length is -1
, all values starting from fromRow
will be returned
Returns column as Future List
of String.
Returns Future null
if there key
is not found.
Throws GSheetsException.
Implementation
Future<List<String>?> columnByKey(
Object key, {
int fromRow = 2,
int length = -1,
}) async {
final cKey = parseKey(key);
checkIndex('fromRow', fromRow);
final columns = await allColumns();
final columnIndex = whereFirst(columns, cKey);
if (columnIndex < 0) return null;
return extractSublist(
columns[columnIndex],
from: fromRow - 1,
length: length,
);
}