xlsxwriter模块实现向Excel表写数据
导入第三方库
import xlsxwriter as xw
写数据
# 创建工作簿
workbook = xw.Workbook(filename)
# 创建子表
worksheet1 = workbook.add_worksheet("sheet1")
# 激活表
worksheet1.activate()
# 设置表头
title = ['序号','项目','数据']
# 从A1单元格开始写入表头
worksheet1.write_row('A1',title)
# 从第二行开始写入数据
i = 2
for j in range(len(data)):
insertData = [data[0][j],data[1][j],data[2][j]]
row = 'A' + str(i)
worksheet1.write_row(row, insertData)
i += 1
# 关闭表
workbook.close()
标签:表写,xlsxwriter,Excel,worksheet1,data,row
From: https://www.cnblogs.com/dxmstudy/p/17303593.html