标签:excel _for 写入 创建 format 时间格式 this number xlsx
work_book = xlsxwriter.Workbook(‘my first.xlsx‘) # 创建一个excel文件,文件名为"my first.xlsx"
如果不指定文件名,默认名字为sheet + 当前sheet的数量
work_sheet1 = work_book.add_worksheet() # 添加shhet1 work_sheet2 = work_book.add_worksheet(‘my excel.xlsx‘) # 添加sheet名字为my excel.xlsx work_sheet3 = work_book.add_worksheet() # 不加参数,默认添加sheet3
work_sheet2.write_string(0, 0, ‘this is write string!‘) work_sheet2.write_number(‘A2‘, 123456) work_sheet2.write_blank(‘A3‘, None) work_sheet2.write_number(‘B1‘, 12) work_sheet2.write_number(‘B2‘, 24) work_sheet2.write_number(‘B3‘, 35) work_sheet2.write_formula(‘B7‘, ‘=sum(b1:b5)‘) work_sheet2.write_datetime(0, 3, datetime.datetime.strptime(‘2019-04-18‘, ‘%Y-%m-%d‘), work_book.add_format({‘num_format‘: ‘yyyy-mm-dd‘}))
work_sheet1.write_boolean(0, 0, True)
work_sheet1.write_url(‘A2‘, ‘http://www.baidu.com‘)
标签:excel _for 写入 创建 format 时间格式 this number xlsx
原文地址:https://www.cnblogs.com/zxw-xxcsl/p/10731138.html