美文网首页
返回前端excel数据流

返回前端excel数据流

作者: butters001 | 来源:发表于2020-09-11 09:37 被阅读0次
# 导出excel
dt = pd.DataFrame(return_dic['logs'], columns=['时间', '类型', '列表项'])
output = io.BytesIO()
# dt.to_excel("/Users/loginfo.xlsx", index=False)
dt.to_excel(output, index=False)
output.seek(0)

response = HttpResponse()
response["Content-Type"] = "application/vnd.ms-excel"
response['Content-Disposition'] = 'attachment;filename=loginfo.xls'
 # response['Access-Control-Expose-Headers'] = 'Content-Disposition'
response.write(output.getvalue())

output.close()
return response

相关文章

网友评论

      本文标题:返回前端excel数据流

      本文链接:https://www.haomeiwen.com/subject/nqrgdhtx.html