Python xlwt写入数据
作者:
崔某 | 来源:发表于
2021-08-20 10:49 被阅读0次# -*- coding: utf-8 -*-
# @Time : 2021/8/20 10:34
# @File : TTT.py
import xlwt
# 创建一个workbook 设置编码
workbook = xlwt.Workbook(encoding='utf-8')
# 设置Excel样式
style = xlwt.XFStyle()
font = xlwt.Font()
font.name = '微软雅黑'
style.font = font
# 创建多个sheet页
for i in range(10):
sheet = workbook.add_sheet(f"sheet_{i}")
# 设置列宽
sheet.col(0).width = 256 * 50
sheet.col(1).width = 256 * 50
sheet.write(0, 0, "哈哈哈")
sheet.write(0, 1, "呵呵呵")
workbook.save("my_excel.xls")
print("生成excel表完成!")
本文标题:Python xlwt写入数据
本文链接:https://www.haomeiwen.com/subject/dqftiltx.html
网友评论