-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patheg3-append.js
36 lines (34 loc) · 1.12 KB
/
eg3-append.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const { google } = require("googleapis");
const auth = require("./credentials-load");
async function run() {
//create sheets client
const sheets = google.sheets({ version: "v4", auth });
//append a range of values (3x3 grid, starting at A5)
const res = await sheets.spreadsheets.values.append({
spreadsheetId: "1t1oIvoknE9fye4LAd2ZYzfIYlu49r5Jf6XbwNKt1saE",
range: "Sheet1!A1:C3",
insertDataOption: "INSERT_ROWS",
valueInputOption: "RAW",
resource: {
values: [
["Xappend 1.1", "append 1.2", "append 1.3"],
["Xappend 2.1", "append 2.2", "append 2.3"],
["Xappend 3.1", "append 3.2", "append 3.3"]
]
}
});
//print results
console.log(JSON.stringify(res.data, null, 2));
// {
// "spreadsheetId": "1t1oIvoknE9fye4LAd2ZYzfIYlu49r5Jf6XbwNKt1saE",
// "tableRange": "Sheet1!A5:C5",
// "updates": {
// "spreadsheetId": "1t1oIvoknE9fye4LAd2ZYzfIYlu49r5Jf6XbwNKt1saE",
// "updatedRange": "Sheet1!A6:C8",
// "updatedRows": 3,
// "updatedColumns": 3,
// "updatedCells": 9
// }
// }
}
run().catch(err => console.error("ERR", err));