陶艺夫
unread,Jul 18, 2009, 9:32:47 PM7/18/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web...@googlegroups.com
Hi, all friends.
I'm using PyExelerator to create Excel report for users to download. I tried to save the Workbook object to a StringIO which is said a file-like object, but the result is an empty file. Following are the codes:
def get_report():
#.... generating workbook codes
f = StringIO.StringIO()
doc = CompoundDoc.XlsDoc()
doc.save_to(f,w.get_biff_data())
#the "doc.save_to" func was added to the Workbook class in the pyExelerator's module by myself. There was a original
#"save" method there take two argument, the first one is a file object, the second one is the same as mine.
response.headers['Content-type']='application/vnd.ms-excel'
response.headers['Content-Disposition']='attachment; filename=test.xls'
response.headers['Content-Title']='test.xls'
response.headers['Content-Length'] = f.tell()
f.seek(0)
return f.read()
What's the problem? Thanks in advance.