Have you looked at xlwt http://www.python-excel.org/ --- https://secure.simplistix.co.uk/svn/xlwt/trunk ?
It claims to have fixed bugs w/ PyExelerator; see https://secure.simplistix.co.uk/svn/xlwt/trunk/xlwt/doc/xlwt.html the Workbook.save() function says it will save to a stream, such as StringIO.... in fact, they seem to have an active google group, and there is an example of saving to StringIO: http://groups.google.com/group/python-excel/browse_thread/thread/581a01953ce3575f/61e40855d94c1eb3?lnk=gst&q=save%28%29#61e40855d94c1eb3 http://www.djangosnippets.org/snippets/1151/ (look for 'output = StrintIO.StringIO()' and 'book.save(output)') Hope that's helpful... 2009/7/18 陶艺夫 <[email protected]> > 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 <[email protected]> > > >> 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, 陶艺夫 <[email protected]> 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

