Thank you for replying. It still does't work. In pyExcelerator, the file object opened to write to is a binary file(opened with "wb" attribute). I don't know whether the StringIO can handle its content as binary data. If it do, how? Or is there something other than StringIO to do so in Python?
2009/7/19 mdipierro <mdipie...@cs.depaul.edu> > > Try replace > > f.seek(0) > return f.read() > > with > > return f.getvalue() > > if it does not work than it is a PyExelerator issue > > On Jul 18, 8:32 pm, 陶艺夫 <artman...@gmail.com> wrote: > > 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. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---