Javascript 我得到一个关于gapi的参考错误

Javascript 我得到一个关于gapi的参考错误,javascript,google-apps-script,google-sheets,referenceerror,Javascript,Google Apps Script,Google Sheets,Referenceerror,我在尝试执行这段代码时遇到了一个引用错误。它指的是gapi部分 以下是指向我的脚本编辑器的链接: const spreadsheetId=“1VMb92O3imLG9nLLVbz5-ypZfnrztSO0Co4CTzj_Fs0U”; const sourceSheetName=“时间飞逝数据”; const destinationSheetName=“TF”; const extractColumns=[11,10,9,8,7,6,5,4,3,2,1];//依次为“A,K,B,J”。 const

我在尝试执行这段代码时遇到了一个引用错误。它指的是gapi部分

以下是指向我的脚本编辑器的链接:

const spreadsheetId=“1VMb92O3imLG9nLLVbz5-ypZfnrztSO0Co4CTzj_Fs0U”;
const sourceSheetName=“时间飞逝数据”;
const destinationSheetName=“TF”;
const extractColumns=[11,10,9,8,7,6,5,4,3,2,1];//依次为“A,K,B,J”。
const transpose=(ar)=>ar[0].map((u,i)=>ar.map(r=>r[i]);
gapi.client.sheets.spreadsheets.values.get({
电子表格ID:spreadsheetId,
范围:sourceSheetName
})。然后((res)=>{
const transposedValues=转置(res.result.values);
const extractedColumns=extractColumns.map(c=>transposedValues[c-1]);
const resultValues=转置(extractedColumns);
gapi.client.sheets.spreadsheets.values.update({
电子表格ID:spreadsheetId,
范围:destinationSheetName,
valueInputOption:“用户输入”
}, {
值:结果值
})。然后((r)=>{
console.log(res.result.values)
},功能(er){
console.error(er.result.error.message);
})
},函数(err){
console.error(err.result.error.message);
});
在解决此问题之前,我的代码不会执行。

gapi是一个“客户端”库(浏览器)。谷歌应用程序脚本。如果不修改整个库以适应服务器环境,则无法在服务器上运行客户端库

要使用apps脚本访问/修改服务器中的Google工作表,您可以使用内置的服务器端库,如。见:


可能会取消阻止链接,以便人们可以看到!错误到底是什么?是哪一行代码产生的?我编辑了这篇文章,所以现在你可以看到第8行的代码a引用错误,其中gapi部分导致itgapi是google客户端库。谷歌应用程序脚本在服务器上运行。请阅读以下内容: