Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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")
share|improve this question
I found something but that will to use another lib, that is xlsxwriter (stackoverflow.com/questions/15667750/coloring-a-tab-in-openpyxl). But, I prefer use less lib as much as possibe. – Deepak Dubey May 29 at 9:45
What do you mean by highlighting the tab: coloring the tab or just making the sheet active? – alecxe May 29 at 11:36
I mean colouring the tab.. – Deepak Dubey May 29 at 12:03
Got it, I bet there is no way to do it via xlwt. – alecxe May 29 at 12:07
How about using from win32com.client import Dispatch ? – Deepak Dubey May 29 at 12:22
show 2 more comments

1 Answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.