From 847fff3be3971caf8ec45566db6edbd37aa4745c Mon Sep 17 00:00:00 2001 From: prasad83 Date: Sun, 19 Mar 2017 15:20:57 +0530 Subject: [PATCH] Option to get list of worksheets. Setting worksheetId: 0 - should give access to valid worksheets. This can help listing available worksheet to user for choosing one. --- lib/spreadsheet.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/spreadsheet.js b/lib/spreadsheet.js index 7055e51..1ab4606 100644 --- a/lib/spreadsheet.js +++ b/lib/spreadsheet.js @@ -20,7 +20,7 @@ exports.create = exports.load = function(opts, callback) { return callback("Missing authentication information"); if (!opts.spreadsheetId && !opts.spreadsheetName) return callback("Missing 'spreadsheetId' or 'spreadsheetName'"); - if (!opts.worksheetId && !opts.worksheetName) + if (typeof worksheetId == 'undefined' && !opts.worksheetName) return callback("Missing 'worksheetId' or 'worksheetName'"); //default to true if useCellTextValues is not set or defined. @@ -68,7 +68,7 @@ Spreadsheet.prototype.init = function(callback) { this.getSheetId('spread', function(err) { if (err) return callback(err, null); _this.getSheetId('work', function(err) { - if (err) return callback(err, null); + if (err && (_this.opts.worksheetId == 0 && !err.match('worksheet (.*) not found'))) return callback(err, null); _this.setTemplates(); callback(null, _this); });