如何,我可以通过python更改Excel工作表选项卡背景颜色

时间:2013-05-29 08:34:14

标签: python python-2.5 xlwt

我正在生成报告,并希望在失败时突出显示该标签。

import xlrd    
import xlwt

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

1 个答案:

答案 0 :(得分:0)

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