0.0
Low commit activity in last 3 years
Excel utils for easy read and write
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 0.8
~> 5.0, < 5.11
~> 0.2
~> 12.0
~> 0.12

Runtime

~> 0.0
~> 2.8
~> 1.2
~> 0.85
 Project Readme

ExcelUtils

Gem Version CI Coverage Status Code Climate

Excel utils for easy read and write

Installation

Add this line to your application's Gemfile:

gem 'excel_utils'

And then execute:

$ bundle

Or install it yourself as:

$ gem install excel_utils

Usage

Write

data = {
  'Sheet1' => [
    {column_a: 1.0, column_b: 'some text'},
    {column_a: 2.0, column_b: 1.35},
    {column_a: 3.0, column_b: Date.parse('2019-08-17')},
    {column_a: 4.0, column_b: nil}
  ],
  'Sheet2' => [
    {'Column 1' => 123.0, 'Column 2' => 'Text 1'},
    {'Column 1' => 456.0, 'Column 2' => 'Text 2'}
  ],
  'Sheet3' => []
}

ExcelUtils.write '/path/to/file.xlsx', data

Read

workbook = ExcelUtils.read '/path/to/file.xlsx'
workbook.to_h => # {'Sheet1' => [{'Column A' => 1, ...}, ...], ...}
sheet = workbook['Sheet1']
sheet.name => # 'Sheet1'
sheet.column_names => # ['Column A', ...]
sheet.each # Implements enumerable module (map, to_a, ...)

workbook = ExcelUtils.read '/path/to/file.xlsx', normalize_column_names: true
workbook.to_h => # {'Sheet1' => [{column_a: 1, ...}, ...], ...}
sheet = workbook.sheets.first
sheet.column_names => # [:column_a, ...]

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/excel_utils.

License

The gem is available as open source under the terms of the MIT License.