from io import BytesIO
from django.utils.encoding import escape_uri_path
bytes_file = BytesIO()
f.write(bytes_file)
bytes_file.seek(0)
file_name = "订单汇总.xls"
response = StreamingHttpResponse(bytes_file)
response['Content-Type'] = 'application/vnd.ms-excel'
response['Content-Disposition'] = 'attachment;filename={}'.format(escape_uri_path(file_name))
# bytes_file.close()
return response
resp = unified_response(code=status.RequestErr, message='请求数据不存在')
return Response(resp)
django实现下载excel
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:pandas 执行sql语句
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
文件下载 excel下载 jxl下载excel pio下载excel
excel下载代码示例:使用两种方式进行excel文件下载,1、使用jxl方式; 需要jxl.jar。2、使用pio方进行扩展。...
文件下载 excel下载 jxl下载excel pio下载excel jar -
【Django】Django 文件下载最佳实践
代码: 参考资料
django 最佳实践 文件下载