Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Gem for easy convertation .xls to .csv with Paperclip
branch: master

Ruby on Rails Paperclip xls to csv Processor

This gem is Paperclip processor, that uses xls2csv to convert .xls to .csv.



gem 'xls_to_csv-paperclip-processor'

xls2csv Instalation

Install xls2csv using your favorite package manager. On OS X, the easiest way to do it is by using Homebrew.

sudo brew install catdoc

Various linux distributions should use similar methods with their respected package managers.

Using Processor

Use it as you would any other Paperclip processor. In your model:

class SomeCsvAttachement < ActiveRecord::Base
  has_attached_file :data,
                    :styles => {
                      :converted => {                       
                         :format => "csv",
                         :params => "-c, -q 3"
                    :path => ":rails_root/data/some_csv_attachements/:id_partition/:basename.:extension",
                    :processors => [:xls_to_csv]

  validates_attachment_content_type :data, :content_type => ['text/csv','text/comma-separated-values','text/csv','application/csv','application/excel','application/','application/vnd.msexcel','text/anytext','text/plain']    

which will convert your .xls document into .csv, and keep both files (.xls and .csv) on the server. If your attachment is not a .xls it will just copy it.

Something went wrong with that request. Please try again.