+ -
当前位置:首页 → 问答吧 → python导出.xls文件时应该return什么

python导出.xls文件时应该return什么

时间:2011-08-18

来源:互联网

Python code

import cherrypy
from pyExcelerator import *
 @cherrypy.expose
    def test(self):
        data=({'id':1,'user':'ying','yest':12,'player_yest':124},{'id':13,'user':'sen','yest':45,'player_yest':1454})
        w = Workbook()
        ws = w.add_sheet('zhaocha_user_count')
       

        ws.write(0,0,'id')
        ws.write(0,1,u'注册用户总数')
        ws.write(0,2,u'新注册数')
        ws.write(0,3,u'新登录数')
 
        for i in range(1,len(data)+1):
            for js in data:
                ws.write(i,0,js['id'])
                ws.write(i,1,js['user'])
                ws.write(i,2,js['yest'])
                ws.write(i,3,js['player_yest'])
         
        cherrypy.response.headers["Content-Type"] = "application/vnd.ms-excel;"

        cherrypy.response.headers['Content-Disposition'] ="attachment;"+"filename=file.xls"

        return 这里应该返回什么

作者: yksalun   发布时间: 2011-08-18

from cherrypy.lib.static import serve_file

作者: iambic   发布时间: 2011-08-18