TypeScript utility to read specific ranges from and append to Google Sheets.
{
"dependencies": {
"@types/node": "^13.13.0",
"googleapis": "^49.0.0",
"ts-node": "^8.8.2"
},
"devDependencies": {
"tslint": "^5.12.0",
"typescript": "^3.2.2"
}
}
- You'll need a GCP project with the Google Sheets API enabled.
- Then create a Service Account under your GCP project and create a JSON key for this user.
- Save the JSON key in the src/secrets folder as 'credentials.json'.
- Define the sheet id and range you wish to access:
- Touch / create a file named sheet-range-ids.json under the src/secrets folder and add "spreadsheetId" and "range" properties referring to your target sheet id and range.
- Or you can declare the "spreadsheetId" and "range" values when instantiating the SheetManager class:
new SheetManager(_spreadsheetId?: string, _range?: string);
- IMPORTANT: You'll now need to share the target sheet with the Service Account's email address. This allows the user to access the sheet via API calls.
- To run the index.ts example implementation use
ts-node index.ts
.