Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 479

Flutter gSheets API: How to insert/append more than one row inside the sheet

$
0
0

Using this https://pub.dev/packages/gsheets

I was able to insert a row but would like to add multiple rows at once. No idea why the google sheets is not filling up with multiple rows

home.dart

for (var i = 0; i < gsIndex; i++)                       {                      Map<String, dynamic> pStatus =                      {                        ParadeState.rank : usersList[i]['RANK'],                        ParadeState.name : usersList[i]['NAME'],                        ParadeState.morningState : dropdownAMValue,                        ParadeState.afternoonState : dropdownPMValue,                        ParadeState.date : formatted,                      };                      print(pStatus);                      await UserSheetsApi.insert([pStatus]);

Console output:

enter image description here

UserSheetsapi.dart

static Future init() async {    try {      final spreadsheet = await _gSheets.spreadsheet(_spreadSheetID);      _userSheet = await _getWorkSheet(spreadsheet, title: 'Sheet1');      final firstRow = ParadeState.getPS();      _userSheet!.values.insertRow(1, firstRow);    } catch (e) {      print('Init Error: $e');    }  }  static Future<Worksheet> _getWorkSheet(      Spreadsheet spreadsheet, {      required String title,  }) async {    try {      return await spreadsheet.addWorksheet(title);    } catch (e) {      return spreadsheet.worksheetByTitle(title)!;    }  }   static insert(List<Map<String, dynamic>> rowList)  {    _userSheet!.values.map.appendRows(rowList);  }

The result:

enter image description here


Viewing all articles
Browse latest Browse all 479

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>