简体   繁体   中英

How, I can change Excel sheet tab background colour by python

I am generating report and want to highlight the tab when its fails.

import xlrd    
import xlwt

wb = Workbook()    
add_result = wb.add_sheet(req_id[req_num])    
wb.save("report_name.xls")
xl = Dispatch( "Excel.Application")

xl.Visible = False

xlFile = "C:/tab_colour.xls"

wkb = xl.Workbooks.Open(xlFile)

sheet = xl.Worksheets.Item("SVP INFO")

sheet.Tab.Color = 255

wkb.Save()

wkb.Close()

xl.Quit()

xl = None

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM