這是將JSON數據拖入Google表格的Google Apps腳本。無權調用setValues() - Google Apps腳本,JSON數據
的代碼是:
function pullJSON() {
var url="https://api.myjson.com/bins/4610d"; // publicly available json
var response = UrlFetchApp.fetch(url); //
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var dataAll = JSON.parse(response.getContentText());
var dataSet = dataAll;
var rows = [],
data;
for (i = 0; i < Object.keys(dataSet).length; i++) {
data = dataSet[Object.keys(dataSet)[i]];
rows.push([data.name]); //JSON entities here
}
dataRange = sheet.getRange(1, 1, rows.length, 1);
dataRange.setValues(rows);
}
在谷歌表格,我通過輸入= pullJSON()插入細胞調用的函數。它顯示錯誤:
「您沒有權限調用setValues(第20行)」,它引用行:dataRange.setValues(rows);
並在單元格A1,A2,A3中產生「未定義」結果。
JSON數據源很簡單:
{"id":1,"name":"A green door","price":12.5}
做這些的目的是爲了能夠將JSON數據轉換成表形式在谷歌片材。
大部分上面的密切關注此主題的內容: "The coordinates or dimensions of the range are invalid" - Google Apps Script and JSON Data
將是任何指導,非常感謝在這個問題上,請。