RailsCasts Pro episodes are now free!

Learn more or hide this

Piyush Gupta's Profile

GitHub User: piyush

Site: http://blog.thebrainpoint.com/

Comments by Piyush Gupta

Avatar

I am pasting my code here, it does the following
- downloads the file, not only make it in file system
- libre complaint, also windows, and browser

Even though I dont like to write and delete , but with spreadsheet seems like the only solution.

ruby
puts "# write the file
    
book.write "Employee_History_#{ params[:id]}.xls"
    
# send the file
    
send_file "Employee_History_#{ params[:id]}.xls", :type => "application/vnd.ms-excel", :filename => "data.xls", :stream => false
    
# and then delete the file
    
File.delete("Employee_History_#{ params[:id]}.xls")"
Avatar

I am pasting my code here, it does the following
- downloads the file, not only make it in file system
- libre complaint, also windows, and browser

Even though I dont like to write and delete , but with spreadsheet seems like the only solution.

ruby
puts "# write the file
    
book.write "Employee_History_#{ params[:id]}.xls"
    
# send the file
    
send_file "Employee_History_#{ params[:id]}.xls", :type => "application/vnd.ms-excel", :filename => "data.xls", :stream => false
    
# and then delete the file
    
File.delete("Employee_History_#{ params[:id]}.xls")"