无法使用google电子表格api v4.0更新单元格的google工作表值



我无法更新特定单元格的工作表行值。我正在使用谷歌api v4.0和谷歌电子表格npm包。我得到一个错误使用它在不和谐bot js。错误是

(node:5956) UnhandledPromiseRejectionWarning: TypeError: rows2[i].save . conf . conf不是函数

检查状态(D:discortbotsrcbot.js:95:30)
我的代码如下:
sheet3 = doc2.sheetsByIndex[sheetIndex]; // Data from back which I have checked is coming correctly!
var rows2 = await sheet3.getRows({
});  
rows2 = rows2.map(a=>a._rawData);
var size = rows2.length;

for(var i=0;i<size;i++){
if(rows2[i][0]==email){
rows2[i].candidateID = userID;
rows2[i].RoleID =  sheetarr[2];
//rows2[i].save(); This one is also not working
console.log(rows2[i].candidateID); // Values are printing in console
console.log(rows2[i].RoleID); // Values are  printing in console
await rows2[i].save(); // Error giving me
verified = 1;
break;
} 

}
if(verified==1){
message.author.send("Your account has been verified.Welcome to Outscal batch!");
}else{
}

我不明白为什么我得到这个错误?请帮助我解决这个问题。

以下修改如何?

修改脚本:

在使用此脚本之前,请再次确认要使用的变量。

var sheet3 = doc2.sheetsByIndex[sheetIndex];
var rows2 = await sheet3.getRows();
// rows2 = rows2.map(a=>a._rawData);  // Removed
var size = rows2.length;
for (var i = 0; i < size; i++) {
if (rows2[i]._rawData[0] == email) {  // Modified
rows2[i].candidateID = userID;
rows2[i].RoleID = sheetarr[2];
console.log(rows2[i].candidateID); // Values are printing in console
console.log(rows2[i].RoleID); // Values are  printing in console
await rows2[i].save();
verified = 1;
break;
}
}
if (verified == 1) {
message.author.send("Your account has been verified.Welcome to Outscal batch!");
} else {
}
参考:

  • node-google-spreadsheet

相关内容

  • 没有找到相关文章

最新更新