Here's how you can read spreadhseets from Google Sheets using googleapis
package. Note that this requires the use of googleapis_auth
package for authentication.
Future readSpreadSheet() async {
final httpClient = await clientViaApplicationDefaultCredentials(scopes: [
StorageApi.devstorageReadOnlyScope,
]);
try {
final spreadsheetApi = SheetsApi(httpClient);
spreadsheetApi.spreadsheets.get(spreadsheetId).then((Spreadsheet spreadsheet) {
// Handle Spreadsheet
// https://pub.dev/documentation/googleapis/latest/sheets.v4/Spreadsheet-class.html
}).onError((error, stackTrace) {
debugPrint('$error: $stackTrace');
});
} finally {
httpClient.close();
}
}
For fetching the spreadsheetId
, you'll be needing to use drive.v3
API from googleapis
package.