Last active
May 30, 2023 05:35
-
-
Save ochilab/66b82b668976803d11c1034072ae41d2 to your computer and use it in GitHub Desktop.
講義資料:GASでシートを読み込んで、JSONで返す例(HTTPのパラメータの受け取り処理はなくても良い)
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
function doPost(e){ | |
var params = JSON.parse(e.postData.getDataAsString()); | |
var data = params.data; | |
//// 以下の範囲独自処理を書く | |
//シートへの書き込み | |
const ss = SpreadsheetApp.getActiveSpreadsheet(); | |
const sheet = ss.getSheetByName('シート1'); | |
// A2セルを選択 | |
var range = sheet.getRange('A2'); | |
var res= range.getValue(); | |
Logger.log(res) | |
//result変数は戻り値となるjson形式を保存 | |
var result = { | |
"result":res | |
}; | |
Logger.log(result); | |
// ///// 独自処理ここまで | |
var out = ContentService.createTextOutput(); | |
out.setMimeType(ContentService.MimeType.JSON); | |
out.setContent(JSON.stringify(result)); | |
return out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment