【发布时间】:2020-05-14 10:03:32
【问题描述】:
我正在尝试使用 Nodejs API v4 将数据写入 Google 表格。我可以成功读取和清除数据,所以我已经正确设置了所有内容。但是,使用文档here 中的示例作为更新方法,我无法弄清楚如何指定要放入 Google 工作表中的数据。我想要一个示例,说明如何将const data 保存的数据粘贴到指定的工作表中。这是我目前所拥有的:
const data = [
[1, 2],
[3, 4],
];
const auth = new google.auth.GoogleAuth({
scopes: ["https://www.googleapis.com/auth/spreadsheets"],
});
const authClient = await auth.getClient();
const sheets = google.sheets({ version: "v4", auth: authClient });
const request = {
spreadsheetId: "my-spreadsheet-id",
range: "Sheet1!A:E",
valueInputOption: "",
resource: {},
auth: authClient,
};
const response = await sheets.spreadsheets.values.update(request);
【问题讨论】:
标签: javascript node.js google-sheets google-api google-sheets-api