cellByKeys method
Fetches cell by names of its column and row.
rowKey
- name of a row with requested cell
The column A considered to be row names
columnKey
- name of a column with requested cell
The first row considered to be column names
Returns Future Cell
.
Returns null
if either rowKey
or columnKey
not found.
Throws GSheetsException.
Implementation
Future<Cell?> cellByKeys({
required dynamic rowKey,
required dynamic columnKey,
}) async {
final rKey = parseKey(rowKey, 'row');
final cKey = parseKey(columnKey, 'column');
final rows = await _ws.values.allRows();
if (rows.isEmpty) return null;
final columnIndex = rows.first.indexOf(cKey);
if (columnIndex < 0) return null;
final rowIndex = whereFirst(rows, rKey);
if (rowIndex < 0) return null;
final value = getOrEmpty(rows[rowIndex], columnIndex);
return Cell._(_ws, rowIndex + 1, columnIndex + 1, value, false);
}