Last active
July 6, 2017 00:28
-
-
Save carlosrymer/8e4cf0a05201f0447db9a23b7a1fd93f to your computer and use it in GitHub Desktop.
A Node snippet to get a Google Sheet's rows using the google-spreadsheet module.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const GoogleSpreadsheet = require('google-spreadsheet'); | |
const spreadsheet = new GoogleSpreadsheet('1tVc-GnBIAAWbdCX7Zn9n-9V8j_rnv7meU22EubLN6G0'); // Sheet ID (visible in URL) | |
spreadsheet.getInfo((sheetError, info) => { | |
if (sheetError) { | |
console.error(sheetError); | |
return sheetError; | |
} | |
const sheet = info.worksheets[0]; | |
const rowOptions = { | |
limit : 100000, | |
offset : 0 | |
} | |
return sheet.getRows(rowOptions, (rowsError, rows) => { | |
if (rowsError) { | |
console.error(rowsError); | |
return rowsError; | |
} | |
return console.log(rows); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment