0.0
No commit activity in last 3 years
No release in over 3 years
An intuitive Google Spreadsheets API wrapper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
~> 0
>= 2.14.1, ~> 2.14
>= 2.8.0, ~> 2.8
>= 1.6.0, ~> 1.16

Runtime

>= 0.7.1, ~> 0.7
>= 1.6.1, ~> 1.6
 Project Readme

GoogleCells

A wrapper for Google's Spreadsheet and Drive APIs.

Installation

Add this line to your application's Gemfile:

gem 'google_cells'

Configuration

Sign up for the Drive API in the Google developer console.

Oauth 2 Web Flow

For a web application using the oauth 2 web flow, configure GoogleCells with your client id and secret.

GoogleCells.configure do |config|
  config.client_id = 'my-client-id'
  config.client_secret = 'my-client-secret'
end

Oauth 2 Service Account

For background processing using a service account, configure GoogleCells with your account email, path to your key file, and key secret.

GoogleCells.configure do |config|
  config.service_account_email = 'my_service_account@email.here'
  config.key_file = File.dirname(__FILE__) + 
    '/path/to/private-key.file/from/Google'
  config.key_secret = 'notasecret'
end

See "examples" directory for implementations of both the web flow and service account in sinatra. To use the examples, add config files with your auth info. to /tmp.

Usage

# list all spreadsheets in account
files = GoogleCells::Spreadsheet.list
files.each do |s|
  p s.title
end

# get spreadsheet by google key
s = GoogleCells::Spreadsheet.get('my-spreadsheet-key-here')

# spread the love
s.share(value:'mybestfriend@email.here', type:'user', role:'writer')

# create a copy of file
c = s.copy

# put spreadsheet in a folder
s.enfold('my-folder-key-here')

# read cell content
w = s.worksheets[0]
w.rows.each do |row|
  row.cells.each do |c|
    p c.value
    p c.input_value
    p c.numeric_value
  end
end

# and write it!
w.rows.from(1).to(2).each do |row|
  row.cells.each do |c|
    c.input_value = "#{cell.row + cell.col}"
  end
end
w.save!

Contributing

  1. Fork it ( http://github.com//google_cells/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request