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




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to