Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Node.js Google Sheets API Integration

This project demonstrates how to integrate the Google Sheets API with a Node.js application. It allows users to read from and write data to a Google Sheet.

Features

  • Write Data: Add new rows to a Google Sheet.
  • Read Data: Retrieve data from a specified range in the Sheet.

Prerequisites

  • Node.js
  • A Google Cloud Platform account with the Sheets API enabled
  • A service account key file (JSON) from Google Cloud Console

Installation

  1. Clone the Repository

    git clone https://github.com/adanzweig/nodejs-google-sheets.git
    cd your-repository
  2. Install Dependencies

    npm install
  3. Set Up Your Credentials

    Place your Google service account key file (e.g., google.json) in the root directory.

Usage

  • Writing Data to Google Sheets

    Call the writeToSheet function with an array of data. Each sub-array represents a row.

    const dataToWrite = [['Name', 'Age', 'Location'], ['Alice', 30, 'New York']];
    writeToSheet(dataToWrite);
  • Reading Data from Google Sheets

    Simply call the readSheet function. It retrieves data from the specified range in the sheet.

    readSheet().then(data => console.log(data));

Configuration

  • Update the spreadsheetId in index.js to point to your target Google Sheet.
  • Adjust the range in the writeToSheet and readSheet functions as needed.

Contributing

Contributions, issues, and feature requests are welcome!

License

This project is licensed under the MIT License.

About

Google Sheets using Nodejs

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages