The more you learn, the easier you learn more!
On the front-end, instead of using Ajax(post, get). I uses window.location
window.location
$("#export-quote-button").click(function(){ var encoded = $.param(getQuoteParams(), true); var url = "/quotes/tran_stats/export_search_result?" + encoded; window.location = url; });
On the back-end, I uses a gem named spreadsheet
spreadsheet
def export_search_result require 'spreadsheet' require 'stringio' Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet #YOUR DATA PROCESSOR HERE file_name = "abc.xls" spreadsheet = StringIO.new book.write spreadsheet send_data(spreadsheet.string, :filename => file_name, :type => "application/vnd.ms-excel") end