Skip to content

Instantly share code, notes, and snippets.

@pochi
Last active December 16, 2015 01:29
Show Gist options
  • Save pochi/5355417 to your computer and use it in GitHub Desktop.
Save pochi/5355417 to your computer and use it in GitHub Desktop.
Convert execl to gist
require 'spreadsheet'
require 'csv'
filename = 'excelsample'
file = File.expand_path(File.dirname(__FILE__) + "/" + filename + '.xls')
excel = Spreadsheet.open(file, 'rb')
CSV.open(filename + '.csv', 'wb') do |csv|
excel.worksheets.each do |sheet|
1.upto(sheet.row_count).each do |row_count|
csv << sheet.row(row_count) unless sheet[row_count,0].nil?
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment