ws = Workbook(encoding='utf-8')
w = ws.add_sheet(u"数据报表第一页")
w.write(0, 0, "id")
w.write(0, 1, u"姓名")
w.write(0, 2, u"年龄")
w.write(1, 0, "1")
w.write(1, 1, "zhen")
w.write(2, 0, "20")
w.write(2, 1, "2")
w.write(3, 0, "qiu")
w.write(3, 1, "21")
output = BytesIO()
ws.save(output)
output.seek(0)
response = HttpResponse(output.getvalue(), content_type='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename=cut_material.xls' # 文件名
response.write(output.getvalue())
return response # 返回文件