Created
February 25, 2010 01:35
-
-
Save bradleybuda/314112 to your computer and use it in GitHub Desktop.
Extract CSVs from an XLSX file with roo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
# wow that's a lot of unnecessary dependencies | |
%w(builder nokogiri rubyzip google-spreadsheet-ruby spreadsheet roo).each { |g| gem g } | |
require 'roo' | |
in_file = ARGV.shift | |
spreadsheet = Excelx.new(in_file) | |
spreadsheet.sheets.each_with_index do |sheet_name, i| | |
spreadsheet.default_sheet = sheet_name | |
out_file = File.expand_path("./#{File.basename(in_file)}_#{sheet_name}.csv") | |
spreadsheet.to_csv(out_file) | |
puts "Wrote sheet #{i + 1} to #{out_file}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment