返回前端excel数据流
# 导出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
网友评论