带有排序数据的GoogleSheet npm包更新表(Node.js)

带有排序数据的GoogleSheet npm包更新表(Node.js),node.js,google-cloud-platform,google-cloud-functions,google-sheets-api,npm-package,Node.js,Google Cloud Platform,Google Cloud Functions,Google Sheets Api,Npm Package,我从HTTP请求的表单中获取数据,在将其写入工作表之前,我想对工作表进行排序。我已经获取了google工作表行,并对它们进行了w.r.t日期排序,但问题是我无法用排序后的数据覆盖google工作表 const doc = new GoogleSpreadsheet('<Google Sheet ID>'); await doc.useServiceAccountAuth({ client_email: '<client email>',

我从HTTP请求的表单中获取数据,在将其写入工作表之前,我想对工作表进行排序。我已经获取了google工作表行,并对它们进行了w.r.t日期排序,但问题是我无法用排序后的数据覆盖google工作表

const doc = new GoogleSpreadsheet('<Google Sheet ID>');
        
await doc.useServiceAccountAuth({
      client_email: '<client email>',
      private_key: "<Private Key>",
});

await doc.loadInfo(); // loads document properties and worksheets
        
const sheet = doc.sheetsById[0]; // or use doc.sheetsByIndex[index]
const rows = await sheet.getRows();
rows.sort(function(o){ return new Date( -o.Timestamp ) });
const doc=新的谷歌电子表格(“”);
等待doc.useServiceAccountAuth({
客户电子邮件:'',
私钥:“”,
});
等待doc.loadInfo();//加载文档属性和工作表
const sheet=doc.sheetsById[0];//或者使用doc.sheetsByIndex[索引]
const rows=wait sheet.getRows();
sort(函数(o){returnnewdate(-o.Timestamp)});

这就是我排序数据的方式。我正在使用谷歌表Npm包。有谁能告诉我如何在google工作表上用新排序的数据写行吗?

假设您使用的是,您可以使用该方法保存更新,如他们的页面上所述