手记

python操作excel

#!/usr/bin/env python
#coding: utf-8
import xlsxwriter

workbook = xlsxwriter.Workbook('demo1.xlsx')
worksheet = workbook.add_worksheet()
worksheet.set_column('A:A', 30)
bold = workbook.add_format({'bold': True})

worksheet.write('A1', 'hello')

worksheet.write('A2', 'workd', bold)

worksheet.write('A2', 'workd', bold)

worksheet.write('B2', u'中文测试', bold)

worksheet.write(3, 0, 44)
worksheet.write(4, 0, 55)
worksheet.write(6, 0, '=SUM(A4:A5)')

workbook.close()

0人推荐
随时随地看视频
慕课网APP