columnByKey method

Future<List<Cell>?> columnByKey(
  1. dynamic key, {
  2. int fromRow = 2,
  3. int length = -1,
})

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 (cells 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 cells starting from fromRow will be returned

Returns column as Future List of Cell.

Throws GSheetsException.

Implementation

Future<List<Cell>?> columnByKey(
  dynamic key, {
  int fromRow = 2,
  int length = -1,
}) async {
  final cKey = parseKey(key);
  checkIndex('fromRow', fromRow);
  final columns = await _ws.values.allColumns();
  final columnIndex = whereFirst(columns, cKey);
  if (columnIndex < 0) return null;
  final list = extractSublist(
    columns[columnIndex],
    from: fromRow - 1,
    length: length,
  );
  return _wrapColumn(list, columnIndex + 1, fromRow);
}