If you need to generate exel files:

1) download and unzip pyXLWriter under yourapp/modules/
2) make an action like

def index():
      table=[['one','two','three'],[1,2,3],[1,4,6]]
      return dict(pages=(('page1',table),('page2',table))

and create a view/generic.xls that contains:

{{
# to use this download and unzip pyXLWriter in applications/[yourapp]/
modules/
import uuid, os
exec('import applications.%s.modules.pyXLWriter as xl' %
request.application)
filename=os.path.join(request.folder,'private','%s.xls' % uuid.uuid4
())
workbook = xl.Workbook(filename)
for pagename,content in pages:
    worksheet = workbook.add_worksheet(pagename)
    for (r,row) in enumerate(content):
        for (c,element) in enumerate(row):
            print '%s%s' % (chr(ord('A')+c),(r+1)), element
            worksheet.write('%s%s' % (chr(ord('A')+c),(r+1)), str
(element))
        pass
    pass
pass
workbook.close()
data = open(filename,'rb').read()
os.unlink(filename)
response.headers['Content-Type']='application/vnd.ms-excel'
response.write(data,escape=False)
}}

then call http://..../index.xls

Massimo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to