Skip to content

Instantly share code, notes, and snippets.

@demimismo
Created August 31, 2012 21:04
Show Gist options
  • Save demimismo/3558968 to your computer and use it in GitHub Desktop.
Save demimismo/3558968 to your computer and use it in GitHub Desktop.
Combine multiple sheets on xls into a single csv
require 'rubygems'
require 'roo'
require 'iconv'
oo = Excel.new("data.xls")
CSV.open("export.csv", "wb") do |csv|
oo.sheets.each do |s|
oo.default_sheet = s
2.upto(oo.last_row) do |i|
csv << (1..6).map {|j| oo.cell(i, j)}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment