Spreet

<img src=“https://badge.fury.io/rb/spreet.png” alt=“Gem Version” /> <img src=“https://secure.travis-ci.org/ekylibre/spreet.png”/>

Universal handler for spreets.

Compatible with Ruby ≥ 1.9.2.

Why ?

This gems is a handler for spreadsheets. With its independent API, it is possible to create, update files in some formats. Today the list is not very long:

  • CSV: UTF-8 with commas (Read & Write)

  • CSV for Excel: CP1252 with semicolons (Read & Write)

  • ODS: Open Document Format (Read & Write with restrictions)

Installation

gem install spreet

How to use it

# Create a new document
doc = Spreet::Document.new
sheet = doc.sheets.add "My Sheet"

# Coordinates can be called with spreadsheet style...
sheet["A1"] = "Last name"
# ...or more classic style...
sheet[1,0] = "First name"
# ...or if necessary as a Hash
sheet[x: 2, y: 0] = "Born on"

sheet.next_row
for person in People.all
  sheet.row person.last_name, person.first_name, person.born_on
end

# Write it as a classic CSV
sheet.write("people-1.csv")
# Write it as a CSV for Excel
sheet.write("people-2.csv", :format=>:xcsv) # CSV for Excel
# or write it as an Open Document Spreadsheet
sheet.write("people-3.ods")

# Read an existing document
doc = Spreet::Document.read("doc.ods")

To do

  • Add style management for cells

  • Add Header/Footer

  • HTML Writer

  • PDF Writer like LibreOffice would make it