Hello
I am trying to create a one button click export to csv, so if a user click he gets a download popup without redirect to new page
my controller (script.py)
@auth.requires_login()
def excelExport():
import csv
import cStringIO
scriptId = request.args[0]
rows = db(db.result.r_id_script == scriptId).select(db.result.r_item1_name, db.result.r_date, db.result.r_time_start,db.result.r_time_end)
s = cStringIO.StringIO()
rows.export_to_csv_file(s, quoting=csv.QUOTE_ALL)
return s.getvalue()
and my view in views/script/view.html
{{ if auth.is_logged_in():}}
{{=A(T('Export EXCEL'), _class='btn btn-primary', callback=URL('script','excelExport', args = request.args[0]))}}
{{pass}}
Function is called but what am I missing to get a download window for file so user can save it as and where he wishes?
and one more question. Is there a way to name column headers in csv?
thank you