Should that be \tmp\? Did it work with just tempararyFile = '/tmp/temp.xls'? Does the \tmp directory exist? Does the user have permission to write there?
Mike -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of new2turbo Sent: Wednesday, July 18, 2007 11:16 AM To: TurboGears Subject: [TurboGears] Re: PyExcelerator This is an application that i inherited and the function used is as follows.... ### Application for downloading into excel####### @expose(content_type="application/excel") def excel(self, *args, **kw): """List records in model""" records = DroppedCalls.select(order_by=[DroppedCalls.c.dt]) try: if not (cherrypy.session['query_results']): raise redirect("list") except: raise redirect("list") records = cherrypy.session['query_results'] """Import to a EXCEL SpreadSheet.""" w = Workbook() ws = w.add_sheet('Query Results') ws.write(0, 0, 'Date') ws.write(0, 1, 'Switch') ws.write(0, 2, 'Cell') ws.write(0, 3, 'Count') rowcount = 0 for row in records: rowcount += 1 colcount = 0 for col in row: try: ws.write(rowcount, colcount, col) except: ws.write(rowcount, colcount, '') colcount += 1 temporaryFile = '/tmp/saved_worksheet-' + str(int(time.time() * 1000)) + '.xls' #tempararyFile = '/tmp/temp.xls' w.save(temporaryFile) f = open(temporaryFile, 'r') return f.read() ................. the error message that I get is -------------------------------- 500 Internal error The server encountered an unexpected condition which prevented it from fulfilling the request. Page handler: <bound method DroppedCallsController.excel of <killermobileapp.DroppedCallsController.controllers.DroppedCallsController object at 0x0180AAB0>> Traceback (most recent call last): File "c:\python24\lib\site-packages\CherryPy-2.2.1-py2.4.egg\cherrypy \_cphttptools.py", line 105, in _run self.main() File "c:\python24\lib\site-packages\CherryPy-2.2.1-py2.4.egg\cherrypy \_cphttptools.py", line 254, in main body = page_handler(*virtual_path, **self.params) File "<string>", line 3, in excel File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg \turbogears\controllers.py", line 334, in expose output = database.run_with_transaction( File "<string>", line 5, in run_with_transaction File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg \turbogears\database.py", line 354, in sa_rwt retval = dispatch_exception(e,args,kw) File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg \turbogears\database.py", line 343, in sa_rwt retval = func(*args, **kw) File "<string>", line 5, in _expose File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg \turbogears\controllers.py", line 351, in <lambda> mapping, fragment, args, kw))) File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg \turbogears\controllers.py", line 378, in _execute_func output = errorhandling.try_call(func, *args, **kw) File "c:\python24\lib\site-packages\TurboGears-1.0.2.2-py2.4.egg \turbogears\errorhandling.py", line 73, in try_call return func(self, *args, **kw) File "F:\project\turbogears\KillerMobileApp\killermobileapp \DroppedCallsController\controllers.py", line 171, in excel w.save(temporaryFile) File "build\bdist.win32\egg\pyExcelerator\Workbook.py", line 547, in save File "build\bdist.win32\egg\pyExcelerator\CompoundDoc.py", line 532, in save IOError: [Errno 2] No such file or directory: '/tmp/ saved_worksheet-1179504517125.xls' --------------------------------------------------- What am I doing wrong here??? Please Help... Is there a better way...... On 18 Jul, 09:25, Marco Mariani <[EMAIL PROTECTED]> wrote: > new2turbo ha scritto: > > > Hi, > > I am trying to download the reports created into excel spreadsheet > > using PyExcelerator but am having trouble. > > Please tell us more. > > > Has anyone has used it before > > Yep > > > or used any other method to do it... > > There has been a thread here on excel & word & ooo a few days ago, with > alternative methods. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

