A library to access Google Drive Spreadsheet API from Node.js https://github.com/bgdavidx/google-drive-spreadsheet
npm install --save google-drive-spreadsheet
Promise version (via Bluebird):
var Spreadsheet = require('google-drive-spreadsheet')
new Spreadsheet(SPREADSHEET_ID).getRowsAsync(1).then(function(rows) {
console.log(rows)
}).catch(function(err) {
console.log('Error', err)
})
Async-Await version (via babel-runtime):
import Spreadsheet from 'google-drive-spreadsheet'
const fn = async () => {
const ss = new Spreadsheet(SPREADSHEET_ID)
try {
const rows = await ss.getRowsAsync(1)
console.log(rows)
} catch (err) {
console.log('Error', err)
}
}
Callback version:
var Spreadsheet = require('google-drive-spreadsheet')
new Spreadsheet(SPREADSHEET_ID).getRows(1, function(err, rows) {
if (err) {
console.log('Error', err)
} else {
console.log(rows)
}
})
Note: Promisified versions also available, omit callback and add async, for example getRows(worksheetId, options, callback)
-> getRowsAsync(worksheetId, options)
returns an array of SpreadsheetRow from the given worksheetId.
example return:
[
{
"_xml": "<entry><id>https://spreadsheets.google.com/feeds/list/1JCqI21cPaw3hn53EC3XdsP_7UacwKxGi5_i472FP-DU/1/public/values/cokwr</id><updated>2015-08-13T07:04:55.399Z</updated><category scheme='http://schemas.google.com/spreadsheets/2006' term='http://schemas.google.com/spreadsheets/2006#list'/><title type='text'>Hello</title><content type='text'>columntwo: world, columnthree: !</content><link rel='self' type='application/atom+xml' href='https://spreadsheets.google.com/feeds/list/1JCqI21cPaw3hn53EC3XdsP_7UacwKxGi5_i472FP-DU/1/public/values/cokwr'/><gsx:columnone>Hello</gsx:columnone><gsx:columntwo>world</gsx:columntwo><gsx:columnthree>!</gsx:columnthree></entry>",
"id": "https://spreadsheets.google.com/feeds/list/1JCqI21cPaw3hn53EC3XdsP_7UacwKxGi5_i472FP-DU/1/public/values/cokwr",
"title": "Hello",
"content": "columntwo: world, columnthree: !",
"_links": [],
"columnone": "Hello",
"columntwo": "world",
"columnthree": "!"
}
]
returns info for each worksheet in the spreadsheet.
adds a row to the worksheet with the given worksheetId.
returns cells (instances of SpreadsheetCell) from the spreadsheet.
returns rows (instances of SpreadsheetRow) from the spreadsheet
returns cells (instances of SpreadsheetCell) from the worksheet.
adds a row to the worksheet.
returns the worksheet converted to a plain Javascript object.
saves the modified spreadsheet row to the cloud.
deletes the row from the cloud.
returns the row converted to a plain Javascript object.
updates the value of the cell in the cloud.
saves the cell to the cloud.
deletes the cell from the cloud.
returns the cell converted to a plain Javascript object.