发布时间:2019-08-07 13:52:57编辑:auto阅读(2066)
首先需要
pip install XlsxWriter
#coding=utf-8
import xlsxwriter
# Create an new Excel file and add a worksheet.
workbook = xlsxwriter.Workbook('demo1.xlsx')
worksheet = workbook.add_worksheet() #新建一个表对象
# Widen the first column to make the text clearer.
worksheet.set_column('A:A', 20) #设置A宽度为20像素
# Add a bold format to use to highlight cells.
#bold = workbook.add_format({'bold': True})
bold = workbook.add_format() #定义一个加粗的格式对象
bold.set_bold()
# Write some simple text.
worksheet.write('A1', 'Hello') #写文字
# Text with formatting.
worksheet.write('A2', 'World', bold)
worksheet.write('B2', u'中文测试', bold)
# Write some numbers, with row/column notation.
worksheet.write(2, 0, 32)
worksheet.write(3, 0, 35.5)
worksheet.write(4, 0, '=SUM(A3:A4)')
# Insert an p_w_picpath.
worksheet.insert_p_w_picpath('B5', 'dog.jpg') #插图片
workbook.close()
上一篇: Python中的If分支与循环
下一篇: MongoDB Python驱动
51719
51379
41809
38583
33063
30073
28743
23740
23648
22017
2240°
2920°
2442°
2387°
2967°
2389°
3198°
5256°
5069°
3623°