You may want to give file name to your excelsheet when you are exporting it. Suppose you want to give the todays date and time as its name. Then do the following:
Suppose export is the method in which you have written the code for exporting excel sheet then do the following:
def export
time = Time.now
time.strftime("%Y-%m-%d %H:%M:%S")
respond_to do |format|
format.html
format.xls { headers["Content-Disposition"] = "attachment; filename=\"#{time}"+".xls"}
end
Suppose export is the method in which you have written the code for exporting excel sheet then do the following:
def export
time = Time.now
time.strftime("%Y-%m-%d %H:%M:%S")
respond_to do |format|
format.html
format.xls { headers["Content-Disposition"] = "attachment; filename=\"#{time}"+".xls"}
end
No comments:
Post a Comment