标签:type bytes get div val excel 使用 panda pandas
最开始是将数据库数据写到本地excel中,再读出来返回给前端,后面发现可以使用BytesIO(),不用再使用本地文件
x_io = BytesIO() df = pd.DataFrame(list(res[‘data‘])) df.to_excel(x_io, sheet_name=table_name, index=False) excel_name = table_name + ‘.xlsx‘ response = HttpResponse() response[‘Content-Type‘] = ‘application/octet-stream‘ response[‘Content-Disposition‘] = ‘attachment;filename="%s"‘ % excel_name response.write(x_io.getvalue()) return response
标签:type bytes get div val excel 使用 panda pandas
原文地址:https://www.cnblogs.com/shouwangrenjian/p/12363088.html