代码拉取完成,页面将自动刷新
from io import BytesIO
import xlwt
from kg_process import connect_datebase
def export_excel(sql, head, line):
list_obj = connect_datebase(sql)
"""导出excel表"""
if list_obj:
# 创建工作簿
ws = xlwt.Workbook(encoding='utf-8')
w = ws.add_sheet('sheet1')
for h in range(0, len(head)):
w.write(0, h, str(head[h]))
excel_row = 1
for obj in list_obj:
for j in range(0, len(line)):
line_name = line[j]
w.write(excel_row, j, obj.get(line_name))
excel_row += 1
output = BytesIO()
ws.save(output)
output.seek(0)
return output
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。