Skip to content

Instantly share code, notes, and snippets.

@developer88
Last active January 1, 2016 08:59
Show Gist options
  • Save developer88/8121975 to your computer and use it in GitHub Desktop.
Save developer88/8121975 to your computer and use it in GitHub Desktop.
Export data to Excel in csv format
# For windows only.
#
csv_string = CSV.generate(col_sep: ";", encoding: 'Windows-1251') do |csv|
csv << "Add some data"
end
send_data(csv_string.encode('Windows-1251'), type: 'text/csv; charset=windows-1251; header=present', disposition: "attachment", filename: "file_to_export.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment