Hello Remi
I change the code as u mentioned but the error that i got was
File "C:\project\KillerMobileApp\killermobileapp\DroppedCallsController
\controllers.py", line 184, in excel
file = StringIO()
NameError: global name 'StringIO' is not defined
^^^^^^^^^^^^^^^^^^^^^^^
my code now looks like this...
@expose(content_type="application/excel")
def excel(self, *args, **kw):
records = AmountSpend.select(order_by=[AmountSpend.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
file = StringIO()
w.save(file)
return file.getvalue()
any idea what I am doing wrong here...
I have been trying to figure this out for a long time.. and I am just
about to give up.....
Many Thanks....
On Jul 19, 1:30 am, remi jolin <[EMAIL PROTECTED]> wrote:
> Hello,
> le 18.07.2007 18:15 new2turbo a écrit:> This is an application that i
> inherited and the function used is as
> > follows....
>
> > temporaryFile = '/tmp/saved_worksheet-' + str(int(time.time() *
> > 1000)) + '.xls'
> > #tempararyFile = '/tmp/temp.xls'
> > w.save(temporaryFile)
>
> > f = open(temporaryFile, 'r')
>
> > return f.read()
>
> > .................
>
> If you get the latestet version in svn, you'll be able to use StringIO
> as the file and use the following that will allow you not to create an
> actual file :
> ...
> file = StringIO()
> w.save(file)
> return file.getvalue()
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---