-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsheet.js
More file actions
37 lines (34 loc) · 776 Bytes
/
sheet.js
File metadata and controls
37 lines (34 loc) · 776 Bytes
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
37
const { GoogleSpreadsheet } = require("google-spreadsheet");
class Sheet {
constructor() {
this.doc = new GoogleSpreadsheet(
"1-QLBfLd2GmCQeSGtdn2ipoFJ-ZrcG2VBlcsi9yLJhss"
);
}
async load() {
await this.doc.useServiceAccountAuth(
require("./dazzling-botany-290007-bb87dfea50ad.json")
);
await this.doc.loadInfo(); // loads document properties and worksheets
}
async addRows(rows) {
const sheet = this.doc.sheetsByIndex[0];
await sheet.addRows(rows);
}
}
module.exports = Sheet;
// Test Code
// (async function () {
// const sheet = new Sheet();
// await sheet.load();
// await sheet.addRows([
// {
// title: "SDE",
// location: "Hyderabad",
// },
// {
// title: "Dessigner",
// location: "Bangalore",
// },
// ]);
// })();