How to get total number of rows with data in a sheet using gsheets dart library?

249 Views Asked by At

Using the gsheets library, I can calculate the total number of rows in a specific sheet:

var sheet = ss.worksheetByTitle('test');
var rows = await sheet?.values.map.allRows();
var totalRows = rows?.length;

However, the above code requires fetching the row data from the sheet. Is it possible to get the total number of rows without fetching the actual data?

2

There are 2 best solutions below

1
On

you can use Worksheet().rowCount;

I found it in this file Gsheets here

0
On

You can easily do this by allRow method here is an example: //get worksheetbytitle first! var allRows = await _workSheet?.values.map.allRows(); var totalRows = allRows?.length; // print row data for (var i = 0; i < allRows!.length; i++) { print(allRows[i]); }

  1. List item