GoogleCells
A wrapper for Google's Spreadsheet and Drive APIs.
Installation
Add this line to your application's Gemfile:
gem 'google_cells'
And then execute:
$ bundle
Or install it yourself as:
$ gem install google_cells
Usage
# configure with Google Service account keys
GoogleCells.configure do |config|
config.service_account_email = '[email protected]'
config.key_file = File.dirname(__FILE__) +
'/path/to/private-key.file/from/Google'
config.key_secret = 'notasecret'
end
# 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:'[email protected]', 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
- Fork it ( http://github.com/
/google_cells/fork ) - Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request