django生成并下载 csv文件:
import csv
download(request, qstr):
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment;filename=%s.csv' %qstr
writer = csv.writer(response)
csvtitle = [u'姓名'.encode('GBK'), u'手机号'.encode('GBK'), u'商品名称'.encode('GBK'), u'售出数量'.encode('GBK'), u'单价(RMB)'.encode('GBK'), u'日期'.encode('GBK')]
writer.writerow(csvtitle)
return response
No comments:
Post a Comment
您的评论将使我blog更有动力~