From 900ce3aae6363f33ca09e6f4a7e6ffa820d678de Mon Sep 17 00:00:00 2001 From: Jedidiah Hurt Date: Thu, 17 Sep 2015 17:14:10 -0600 Subject: [PATCH] Add GoogleSpreadsheet.bulkUpdateCells() --- index.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/index.js b/index.js index 97e44e3..558fdb9 100644 --- a/index.js +++ b/index.js @@ -270,6 +270,38 @@ var GooogleSpreadsheet = function( ss_key, auth_id, options ){ cb( null, cells ); }); } + + // this.bulkUpdateCells = function (worksheet_id, cells, values, cb) { + // var entries = cells.map((cell, i) => { + // return ` + // ${cell.id} + // + // ${cell.id} + // + // + // ` + // }); + // var worksheetUrl = `https://spreadsheets.google.com/feeds/cells/${ss_key}/${worksheet_id}/private/full`; + // var data_xml = ` + // ${worksheetUrl} + // ${entries.join("\n")} + // ` + // console.log(data_xml); + // self.makeFeedRequest(`https://spreadsheets.google.com/feeds/cells/${ss_key}/${worksheet_id}/private/full/batch`, + // 'POST', data_xml, cb) + // } + + this.bulkUpdateCells = function (worksheet_id, cells, values, cb) { + var entries = cells.map(function (cell, i) { + return "\n " + cell.id + "\n \n " + cell.id + "\n \n \n "; + }); + var worksheetUrl = "https://spreadsheets.google.com/feeds/cells/" + ss_key + "/" + worksheet_id + "/private/full"; + var data_xml = "\n " + worksheetUrl + "\n " + entries.join("\n") + "\n "; + self.makeFeedRequest("https://spreadsheets.google.com/feeds/cells/" + ss_key + "/" + worksheet_id + "/private/full/batch", 'POST', data_xml, cb); + }; }; // Classes