Simple Spreadsheet

Recently a wrote a module to import raw data from Excel-like files to database and export it in various formats. To accomplish this i have to use different gems with different usage patterns so I decide to wrap them in a single simple gem. This is a spreadsheet reader and writer that (will) supports common formats: CSV (.csv), Excel (.xls, .xlsx), Open-office (.ods) and Google (online).

Used gems:

Installing

Add to your Gemfile and run the bundle command to install it.

 gem "simple-spreadsheet"

N.B. Requires Ruby 1.9.2 or later.

Basic functionality

Reading Spreadsheet

Example:

s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.xls")

Supported formats:

Excel (.xls) Excelx (.xlsx) Openoffice (.ods) CSV (.csv) CSV Excel CSV Tab Separated
Yes Yes Yes Yes Yes Yes

Recipes

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

s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.xls")
s.select_worksheet = s.sheets.first
s.first_row.upto(@workbook.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)

s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.xls")
s.first_row.upto(@workbook.last_row) do |line|
  data1 = s.cell(line, 1, 1)
  data2 = s.cell(line, 3, 1)
end

Accessing CSV Excel (semicolon separated)

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

Accessing CSV Tab separated

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

Future plans