Google spreadsheet manipulation
NPM : https://www.npmjs.com/package/google-spreadsheet
Doc: https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication
Google sheet API doc: https://developers.google.com/sheets/api/quickstart/js?hl=fr
👉 Activate your Sheet API 👈
Go to the Google Developers Console
Setup Instructions for service account Follow steps above to set up project and enable sheets API
Open zenv and copy your key in folder
open .
Install NPM dependency
npm i google-spreadsheet --save
const { GoogleSpreadsheet } = require('google-spreadsheet');
const creds = require('./myapp-spreadsheet.json');
// Initialize the sheet - doc ID is the long id in the sheets URL
const doc = new GoogleSpreadsheet('YOUR_SPREADSHEET_ID');
await doc.useServiceAccountAuth(creds);
await doc.loadInfo(); // loads document properties and worksheets
console.log(doc.title);
await doc.updateProperties({ title: 'renamed doc' });
const sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id] or doc.sheetsByTitle[title]
console.log(sheet.title);
console.log(sheet.rowCount);
// adding / removing sheets
const newSheet = await doc.addSheet({ title: 'hot new sheet!' });
//await newSheet.delete();