Giter VIP home page Giter VIP logo

google_sheets's Introduction

Google Sheets

This API allows simplified access to Google Sheets.

Installation

In your Gemfile:

gem "google_sheets", "~> VERSION"

Limitations

  • This gem only provides functionality to replace and get spreadsheets.

Environment

The rake task uses the following environment variables

  • SPREADSHEET_ID=<id_of_spreadsheet>
  • KEY_PATH=<path_to_keyfile>
  • CSV_PATH=<path_to_csv>

Usage

rake replace_spreadsheet

Running the test suite

bundle exec rake

Documentation

To gain access to a spreadsheet in Google Sheets:

  1. Create a new, empty Google spreadsheet and note the Spreadsheet ID, which can be found as part of the URL. If the URL is: https://docs.google.com/spreadsheets/d/1UgxVGDt8X0YgB9JYRVQipCqa-nwcnZkKbm0ULOJgEYc/edit#gid=0,
    then the Spreadsheet ID would be: 1UgxVGDt8X0YgB9JYRVQipCqa-nwcnZkKbm0ULOJgEYc.
  2. Visit the Google Api Manager at: https://console.cloud.google.com/apis/library.
  3. Click Library->Sheets API and if necessary create a new project.
  4. Enable the Google Sheets API.
  5. Click Credentials -> Create Credentials -> Service Account Key.
  6. If necessary, create a new 'service account', with a role: Project->Owner.
  7. Create a new JSON key and save this file somewhere.
  8. Go back to the Google Spreadsheet and share it with the e-mail address of the service account. This can be found in the Key File under client_email.

To initialise:

sheets = GoogleSheets.new(key_file: , sheet_name: )
  • keyfile: path the JSON key file saved in step 7.
  • sheet_name(optional): The name of the sheet to use. Defaults to 'Sheet1'.

To get values in a sheet

sheets.get_document(sheet_id:, range: ).values

To replace a spreadsheet:

sheets.replace_document(sheet_id:, data:, range: )
  • sheet_id: The ID of the spreadsheet (step 1).
  • data: A two dimensional array of data to upload to the spreadsheet.
  • range(optional) Range to replace in A1 notation.

License

The gem is available as open source under the terms of the MIT License.

google_sheets's People

Contributors

koetsier avatar

Watchers

Simon Whatley avatar Steve Laing avatar Anika Henke avatar Pete avatar Ryan MacGillivray avatar minglis avatar Kelvin Gan avatar Pete Goddard avatar Minno avatar David Illsley avatar Richard Baker avatar Tom avatar James Cloos avatar  avatar Mateusz Grotek avatar Adrian Clay avatar Chris Blackburn avatar Mark Hurrell avatar Tara Stockford avatar Andrew Leimdorfer avatar Rhian Lewis avatar  avatar Dr Keith Mitchell avatar Ash Chohan avatar Jani Kraner avatar Somme avatar Keith Lawrence avatar  avatar Barbara Slawinska avatar Dilwoar Hussain avatar Johnathan Ishmael avatar  avatar Karl Baker avatar  avatar Leena Gupte avatar Rosa Fox avatar  avatar David Trussler avatar Jonathon Shire avatar Stephen Harker avatar Kevin Garwood avatar  avatar  avatar  avatar  avatar  avatar Shahina Rahman avatar Kyle MacPherson avatar Tasmin Steer avatar Rachel Smith avatar z-gooch avatar Jess Jones avatar Richard Morton avatar  avatar George Eaton avatar Felix Harrison avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.