Skip to content

Instantly share code, notes, and snippets.

@AWtnb
Created July 31, 2019 12:58
Show Gist options
  • Save AWtnb/aeb1c650547151f22e18085550f54a35 to your computer and use it in GitHub Desktop.
Save AWtnb/aeb1c650547151f22e18085550f54a35 to your computer and use it in GitHub Desktop.
API to get data on google sheet
/*
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