Hello,

My web2py (1.99.5) app is on GAE. I would like to serve Excel file right 
from the controller. I have managed to prepare wb object to serve:

-----------------------------------------------------------------------------------
def serve_xls_file():

import xlwt
import cStringIO
stream = cStringIO.StringIO()    
wb = xlwt.Workbook()
ws = wb.add_sheet('Sheetname')   
ws.write(0, 0, 'one')
ws.write(0, 1, 'two')
ws.write(1, 0, 'three')
ws.write(1, 1, 'four')

wb.save(stream)


---------------------------------------------------------------

Now I would like to serve Workbook object (wb) as a file. 

I have tried put the following in controller after creating wb: 

response.headers['Content-Type'] = 'application/vnd.ms-excel'
attachment = 'attachment; filename=' + 'file.xls'
response.headers['Content-Disposition'] = 'attachment; filename=file.xls'
content = wb
raise HTTP(200,content, **{'Content-Type':'application/vnd.ms-excel', 
'Content-Disposition':attachment + ';'})   

But it did not work as expected. 

I would appreciate your guidance.

MJ


-- 



Reply via email to