vue+element UI +Django+mysql实现下载数据表为excel
后台代码,在url.py自行定义接口,浏览器访问即可下载
import MySQLdb
import xlwt
from io import BytesIO
from django.shortcuts import HttpResponse
from MySQLdb.cursors import DictCursor
def export_xls_out(request):
conn = MySQLdb.connect(host='',user='',passwd='',db='',port=3306,charset='utf8',cursorclass=MySQLdb.cursors.DictCursor)
#数据库参数自己配置
sql='select * from test'
cur = conn.