练习:#生成一个excel文件,生成3个sheet,每个sheet的a1写一下sheet的名称。每个sheet有个底色

#coding=utf-8

from openpyxl import Workbook

wb=Workbook()

ws1=wb.create_sheet('sheet1',0)

ws2=wb.create_sheet('sheet2',1)

ws3=wb.create_sheet('sheet3',2)

ws1['A1']=ws1.title

ws2['A1']=ws2.title

ws3['A1']=ws3.title

ws1.sheet_properties.tabColor='1072BA'

ws2.sheet_properties.tabColor='1072BA'

ws3.sheet_properties.tabColor='1072BA'

wb.save('d:\\sample.xlsx')

python excel操作 练习:#生成一个excel文件,生成3个sheet,每个sheet的a1写一下sheet的名称。每个sheet有个底色-LMLPHP

04-18 09:33