python 写excal

 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)
View Code
posted @ 2016-01-18 18:02  acvc  阅读(224)  评论(0编辑  收藏  举报