# -*- coding: utf-8 -*-
import models
from models import Student
from django.shortcuts import render_to_response,render
from pyExcelerator import *
import time
# -*- coding: utf-8 -*-
def index(req):
w=Workbook()
ws=w.add_sheet("sheet")
ws.write(0,0,u"姓名")
ws.write(0,1, u"班级")
ws.write(0,2,u"年龄")
ws.write(0,3,u"性别")
student=Student.objects.all()
data1=[]
data=[]
for i in student.values():
data1.append(i["name"])
data1.append(i["grade"])
data1.append(i["age"])
data1.append(i["sex"])
data.append(data1)
data1=[]
for k in range(len(data)):
for j in range(len(data[k])):
ws.write(k+1,j,data[k][j])
k+=1
print data
w.save(u"学生.xls")
return render_to_response(‘index.html‘, {‘‘})
************************************************************
导出效果