class XlsController < ApplicationController
...
def get_xls
data = validate_params
form = Form.new(data)
if form.save
filename = "form-#{Time.now.strftime("%Y%m%d%H%M%S")}.xls"
send_data([data].to_xls, :type => "text/xls; charset=utf-8; header=present", :filename => filename)
else
render nothing: true
end
end
...
end