主要使用pandas

from flask import Response
@login_blu.route('/download') def download(): import pandas as pd from io import BytesIO # 内存管理器(excel存入内存) excel = pd.DataFrame(list)#二维数组,对应表头的相应数据 excel.columns = header_list #表头 [xx,xx,xx,xx] file = BytesIO() excel.to_excel(file, index=False) response = Response(content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') execl_name = 'excel下载.xlsx' response.headers["Content-disposition"] = 'attachment; filename=%s' % execl_name.encode().decode('latin-1') response.data = file.getvalue() return response

相关文章:

  • 2022-12-23
  • 2021-07-27
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
猜你喜欢
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
相关资源
相似解决方案