1 import xlwt
2
3 # 创建一个workbook
4 workbook = xlwt.Workbook(encoding=‘utf-8‘)
5 style_head = xlwt.easyxf(‘font: bold on‘)
6
7 # 增加一个sheet页
8 worksheet = workbook.add_sheet(sheet_name)
9
10 # 写入数据
11 worksheet.write(0, 0, ‘title‘, style_head) # x=0, y=0的单元格
12 worksheet.write(1, 0, 123) # x=0, y=1的单元格
13
14
15 # 保存到文件
16 workbook.save(filename)
时间: 2024-10-11 05:49:14