Created
March 8, 2020 08:38
-
-
Save plateaukao/a3b7f6216c85121e6addef3090b641ca to your computer and use it in GitHub Desktop.
google app script: query data from googl 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
function doGet(request) { | |
//var spreadsheetId = '14UvTqbN3jxOnXj59HilYllfjetV6eGv6WevQsw---axx'; | |
//var rangeName = 'A2:D'; | |
var spreadsheetId = request.parameter.id; | |
var rangeName = request.parameter.range; | |
var values = Sheets.Spreadsheets.Values.get(spreadsheetId, rangeName).values; | |
if (!values) { | |
Logger.log('No data found.'); | |
} else { | |
Logger.log('Vocab, Explanation, Hanja, Sentence:'); | |
for (var row = 0; row < values.length; row++) { | |
// Print columns A and E, which correspond to indices 0 and 4. | |
Logger.log(' - %s, %s, %s, %s', values[row][0], values[row][1], values[row][2], values[row][3]); | |
} | |
} | |
var myJSON = JSON.stringify(values) | |
return ContentService.createTextOutput(myJSON).setMimeType(ContentService.MimeType.JSON); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment