Last active
May 1, 2024 13:43
-
-
Save khanhkhuu/95f48bae395010bff6fabe959ba7c993 to your computer and use it in GitHub Desktop.
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
var OAUTH_KEY = 'H9f2A4AyGlnigY0LwvzA4Q6FRmR2Aqxxxxxxx'; | |
function getData(smartsheet_id) { | |
const url = "https://api.smartsheet.com/2.0/sheets/" + smartsheet_id; | |
const options = { 'headers': { "Authorization": "Bearer " + OAUTH_KEY } }; | |
const ar = []; | |
var response = UrlFetchApp.fetch(url, options); | |
var result = JSON.parse(response.getContentText()); | |
const tab2 = []; | |
for (var i in result.columns) { | |
var x = result.columns[i]["title"]; | |
tab2.push(x); | |
} | |
ar.push(tab2); | |
for (const row in result.rows) { | |
const cells = result.rows[row]["cells"]; | |
const tab = []; | |
for (const cell in cells) { | |
const value = cells[cell]["value"] == undefined ? "" : cells[cell]["value"]; | |
tab.push(value); | |
} | |
ar.push(tab); | |
} | |
return ar; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment