这是函数:
function sumForProduct(code, week) {
const idMainSheet = "...{some_id}...";
const ss = SpreadsheetApp.openById(idMainSheet);
const listPrice = ss.getSheetByName("...{some_name}...");
const data = listPrice.getDataRange().getValues();
const idxCode = data[0].indexOf("code");
const idxCount = data[0].indexOf("count");
const idxPrice = data[0].indexOf("price");
const idxWeek = data[0].indexOf("week");
let idxString = -1;
for (let i = 2; i < data.length; i++) {
if (data[i][idxWeek] === week && data[i][idxCode] === code) {
idxString = i;
break;
}
}
const count = Number(data[idxString][idxCount]);
const price = Number(data[idxString][idxPrice]);
return count * price;
}
一切都通过控制台进行;当我想调用表中的公式时:=sumForProduct($D6;E$4),然后出现错误:Exception: You do not have permission to call SpreadsheetApp.openById. Required permissions: https://www.googleapis.com/auth/spreadsheets (строка 4).,如何获得使用 openById 的权限?