Created
July 31, 2019 12:58
-
-
Save AWtnb/aeb1c650547151f22e18085550f54a35 to your computer and use it in GitHub Desktop.
API to get data on google sheet
This file contains 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
/* | |
googleスプレッドシート内の情報を返すAPI | |
*/ | |
function getDataOnSheet() { | |
var SHEET_ID = PropertiesService.getScriptProperties().getProperty("SHEET_ID"); | |
var sht = SpreadsheetApp.openById(SHEET_ID).getSheets(); | |
var maxRow = sht[0].getLastRow(); | |
var data = sht[0].getRange(2, 1, maxRow - 1, 4).getValues(); | |
var ret = []; | |
for (var r = maxRow - 2; r >= 0; r--) { | |
ret.push(data[r].join("\t")); | |
} | |
return ret.join("\n"); | |
} | |
function doGet(e) { | |
var data = getDataOnSheet(); | |
return ContentService.createTextOutput(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment