# Simple Spreadsheet [![Code Climate](https://codeclimate.com/github/zenkay/simple-spreadsheet/badges/gpa.svg)](https://codeclimate.com/github/zenkay/simple-spreadsheet) [![Travis CI](https://travis-ci.org/zenkay/simple-spreadsheet.svg?branch=master)](https://travis-ci.org/zenkay/simple-spreadsheet) [![Gem Version](https://badge.fury.io/rb/simple-spreadsheet.svg)](http://badge.fury.io/rb/dandelionapi) [![Coverage Status](https://coveralls.io/repos/github/zenkay/simple-spreadsheet/badge.svg?branch=master)](https://coveralls.io/github/zenkay/simple-spreadsheet?branch=master) 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: ```ruby 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 ```ruby 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) ```ruby 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) ```ruby require "simple-spreadsheet" s = SimpleSpreadsheet::Workbook.read("my_spreadsheets_file.csv", ".csvx") ``` ### Accessing CSV Tab separated ```ruby 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 - 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/)