Python excel operation practice: #Generate an excel file, generate 3 sheets, and write the name of the sheet in a1 of each sheet. Each sheet has a background color

Exercise: #Generate an excel file, generate 3 sheets , and write the name of the sheet in a1 of each sheet . Each sheet has a background color

#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')

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324776575&siteId=291194637