Skip to content

Instantly share code, notes, and snippets.

@javiercbk
Last active August 31, 2016 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javiercbk/4143466947a56c5052ac79af9e9c7ce4 to your computer and use it in GitHub Desktop.
Save javiercbk/4143466947a56c5052ac79af9e9c7ce4 to your computer and use it in GitHub Desktop.
var Spreadsheet = require('./spreadsheets').Spreadsheet;
const RAW = "RAW";
var spreadsheet = new Spreadsheet();
var authorizePromise = spreadsheet.authorize();
authorizePromise.then(function(){
//spreadsheetId should be replace with the actual spreadsheet id
//sheetname should be replaced with the actual sheetname
//this will read all the rows from D3 to F4
return spreadsheet.getRows('spreadsheetId', 'sheetname!D3:F4');
}).then(function(rows){
//print those rows
console.log('rows: ' + JSON.stringify(rows));
}).then(function(){
var payload = {
//you can use COLUMNS to write up to down or ROWS to write left to right
"majorDimension": "COLUMNS", // "majorDimension": "ROWS"
"values": [{values: [123]}, {values: ['the dude abides']}, {values: [123.213]}]
};
//this will write the values in starting from ROW D3.
return spreadsheet.editRows('spreadsheetId', payload, 'sheetname!D3:F4', RAW);
}).catch(function(err){
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment