Project

excel2csv

0.0
No commit activity in last 3 years
No release in over 3 years
gem for converting Excel files to csv
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
>= 2.8
 Project Readme

Excel2CSV: gem for converting Excel files to csv

Installation and usage

gem install excel2csv

With Gemfile

gem 'excel2csv'

Requirements

  1. Ruby > 1.9.2
  2. Java Runtime

Usage

require 'excel2csv'

# Read csv, xls, xlsx files like with CSV#read
Excel2CSV.read "path/to/file.csv", encoding:"windows-1251:utf-8"
# by default Excel2CSV reads first worksheet
Excel2CSV.read "path/to/file.xls"  # working encoding is always UTF-8
Excel2CSV.read "path/to/file.xlsx" # working encoding is always UTF-8

# Line by line reading like with CSV#foreach
Excel2CSV.foreach("path/to/file.csv", encoding:"windows-1251:utf8") {|r| puts r}
Excel2CSV.foreach("path/to/file.xls") {|r| puts r}
Excel2CSV.foreach("path/to/file.xlsx") {|r| puts r}

# Read non first worksheet
Excel2CSV.read "path/to/file.xls", sheet:1 #reads second sheet 
Excel2CSV.read "path/to/file.xlsx", sheet:2 #reads third sheet


# Preview first N rows in big files
Excel2CSV.read "path/to/file.xls", rows: 2, preview: true
Excel2CSV.read "path/to/file.xlsx", rows: 2, preview: true
Excel2CSV.read "path/to/file.csv", rows: 2, preview: true