No commit activity in last 3 years
No release in over 3 years
A Ruby gem that streams and parses large Excel(xlsx and xlsm) files fast and efficiently.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
~> 2.13.0

Runtime

~> 1.6.0
>= 1.0.0
 Project Readme

Creek – Stream parser for large Excel(xlsx and xlsm) files.¶ ↑

Creek is a Ruby gem that provide a fast, simple and efficient method of parsing large Excel(xlsx and xlsm) files.

Installation¶ ↑

Creek can be used from the command line or as part of a Ruby web framework. To install the gem using terminal, run the following command:

gem install creek

To use it in Rails, add this line to your Gemfile:

gem "creek"

Basic Usage¶ ↑

Creek can simply parse an Excel file by looping through the rows enumerator:

require 'creek'
creek = Creek::Book.new "specs/fixtures/sample.xlsx"
sheet= creek.sheets[0]

sheet.rows.each do |row|
  puts row # => {"A1"=>"Content 1", "B1"=>nil, C1"=>nil, "D1"=>"Content 3"}
end

sheet.rows_with_meta_data.each do |row|
  puts row # => {"collapsed"=>"false", "customFormat"=>"false", "customHeight"=>"true", "hidden"=>"false", "ht"=>"12.1", "outlineLevel"=>"0", "r"=>"1", "cells"=>{"A1"=>"Content 1", "B1"=>nil, C1"=>nil, "D1"=>"Content 3"}}
end

sheet.state   # => 'visible'
sheet.name    # => 'Sheet1'
sheet.rid     # => 'rId2'

Filename considerations¶ ↑

By default, Creek will ensure that the file extension is either *.xlsx or *.xlsm, but this check can be circumvented as needed:

path = 'sample-as-zip.zip'
Creek::Book.new path, :check_file_extension => false

By default, the Rails file_field_tag uploads to a temporary location and stores the original filename with the StringIO object. (See this section of the Rails Guides for more information.)

Creek can parse this directly without the need for file upload gems such as Carrierwave or Paperclip by passing the original filename as an option:

# Import endpoint in Rails controller
def import
  file = params[:file]
  Creek::Book.new file.path, check_file_extension: false
end

Contributing¶ ↑

Contributions are welcomed. You can fork a repository, add your code changes to the forked branch, ensure all existing unit tests pass, create new unit tests cover your new changes and finally create a pull request.

After forking and then cloning the repository locally, install Bundler and then use it to install the development gem dependecies:

gem install bundler
bundle install

Once this is complete, you should be able to run the test suite:

rake

Bug Reporting¶ ↑

Please use the Issues page to report bugs or suggest new enhancements.

License¶ ↑

Creek has been published under MIT License