Skip to content

Simple spreadsheet is a Ruby Gem reader for common spreadsheet formats: Excel (.xls, .xlsx), Open-office (.ods) and CSV (standard, excel, tab separated)

License

Notifications You must be signed in to change notification settings

zenkay/simple-spreadsheet

Repository files navigation

Simple Spreadsheet

Code Climate Travis CI Gem Version Coverage Status

A spreadsheet reader and (in the future) writer that supports common formats: CSV (.csv), Excel (.xls, .xlsx), Open-office (.ods) and Google (online).

Installation

Add this line to your application's Gemfile:

gem 'simple-spreadsheet'

And then execute:

$ bundle install

Functionalities

Reading Spreadsheet

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

Recipes

Get all data from some cols of first sheet of a XLS file

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

Get all data from some cols of first sheet of a XLS file (option 2)

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

Accessing CSV Excel (semicolon separated)

require "simple-spreadsheet"

s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.csv", ".csvx")

Accessing CSV Tab separated

require "simple-spreadsheet"

# specify format
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.csv", ".csvt")
# use .tsv
s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.tsv")

Future plans

  • 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

Credits

About

Simple spreadsheet is a Ruby Gem reader for common spreadsheet formats: Excel (.xls, .xlsx), Open-office (.ods) and CSV (standard, excel, tab separated)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages