a-marenkov / gsheets

A Dart library for working with Google Sheets API.
Other
79 stars 31 forks source link

How to appendRow multiple times? #28

Closed aldhosutra closed 4 years ago

aldhosutra commented 4 years ago

Hello, i need to append multiple data in a single time, so i need to call appendRow in a loop. But, in the google sheet, i see that only one row being appended. Is this some kind of issue?

thanks, btw great project, very helpful

a-marenkov commented 4 years ago

Hi @aldhosutra

If you would like to append multiiple rows, you should use appendRows.

Regarding your issue - most likely you've forgot to add await keyword.

for/while loop {
   await sheet.values.appendRow(values);
}

But you should avoid using loops - there is going to be a request for each iteration.

Thanks for checking out gsheets!

a-marenkov commented 4 years ago

Here is an example

final values = [
['a', 'b', 'c'],
['1', '2', '3'],
['a1', 'b2', 'c3'],
];

await sheet.values.appendRows(values);
aldhosutra commented 4 years ago

Hello, your code works perfectly

thanks, this is a great library, great help!