Forked from danthareja/cacheGoogleSheetNotesAndFormulas.js
Last active
August 29, 2015 14:22
-
-
Save dsernst/e833f3a9812fc943a10a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ?id=<GOOGLE_SHEET_ID> | |
function doGet(request) { | |
if (!request.parameter.id) { | |
return ContentService.createTextOutput(JSON.stringify(new Error('no Google Sheet id set'))) | |
.setMimeType(ContentService.MimeType.JSON); | |
} | |
var cache = cacheNotesAndFormulas(request.parameter.id); | |
// Return cache as JSON | |
return ContentService.createTextOutput(JSON.stringify(cache)) | |
.setMimeType(ContentService.MimeType.JSON); | |
} | |
function cacheNotesAndFormulas(spreadsheetId) { | |
return SpreadsheetApp | |
.openById(spreadsheetId) | |
.getSheets() | |
.reduce(function(cache, sheet) { | |
var sheetData = cache[sheet.getName()] = {}; | |
var range = sheet.getDataRange(); | |
sheetData.range = range.getA1Notation(); | |
sheetData.notes = range.getNotes(); | |
sheetData.formulas = range.getFormulas(); | |
return cache; | |
}, {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment