Skip to content

TS utility to read form and write to google sheets using googleapis sheets v4

Notifications You must be signed in to change notification settings

cssimsek/gsheets-service-ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TS utility to read from and write to Google Sheets using googleapis sheets v4

Purpose

TypeScript utility to read specific ranges from and append to Google Sheets.

Dependencies:

{
    "dependencies": {
        "@types/node": "^13.13.0",
        "googleapis": "^49.0.0",
        "ts-node": "^8.8.2"
    },
    "devDependencies": {
        "tslint": "^5.12.0",
        "typescript": "^3.2.2"
    }
}

How to use:

  1. You'll need a GCP project with the Google Sheets API enabled.
  2. Then create a Service Account under your GCP project and create a JSON key for this user.
  3. Save the JSON key in the src/secrets folder as 'credentials.json'.
  4. 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);
  5. 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.
  6. To run the index.ts example implementation use ts-node index.ts.

About

TS utility to read form and write to google sheets using googleapis sheets v4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published