A spreadsheet reader and (in the future) writer that supports common formats: CSV (.csv), Excel (.xls, .xlsx), Open-office (.ods) and Google (online).
Add this line to your application's Gemfile:
gem 'simple-spreadsheet'
And then execute:
$ bundle install
Example:
require "simple-spreadsheet"
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.xls")
Supported formats:
Excel (.xls) | Excelx (.xlsx) | Openoffice (.ods) | CSV (.csv) | CSV Excel | CSV Tab Separated | |
---|---|---|---|---|---|---|
Reading whole file | Yes | Yes | Yes | Yes | Yes | Yes |
Reading line by line | Yes | - | - | Yes | Yes | Yes |
require "simple-spreadsheet"
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.xls")
s.selected_sheet = s.sheets.first
s.first_row.upto(s.last_row) do |line|
data1 = s.cell(line, 1)
data2 = s.cell(line, 3)
end
require "simple-spreadsheet"
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.xls")
s.first_row.upto(s.last_row) do |line|
data1 = s.cell(line, 1, 1)
data2 = s.cell(line, 3, 1)
end
require "simple-spreadsheet"
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.csv", ".csvx")
require "simple-spreadsheet"
# specify format
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.csv", ".csvt")
# use .tsv
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.tsv")
- Reading support for all formats
- More efficient reading for big spreadsheets (adding sequential reading to Roo standard methods)
- Writing support for all formats
- More reading functionalities
- Edit support for all formats
- Roo (http://roo.rubyforge.org/)
- Spreadsheet (http://rubyforge.org/projects/spreadsheet/)
- SimpleZSLWriter (http://rubyforge.org/projects/simplxlsxwriter/)
- XLSX (http://rubygems.org/gems/xlsx)
- WriteExcel (https://github.com/cxn03651/writeexcel/)