Python Forum

Full Version: Need to identify sheet color in excel workbook
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I have a given excel workbook that has multiple sheets. Some of these sheets have a colored background to them. Unfortunately, I am having trouble attaching a screenshot of this but I basically need to identify sheets that have a blue background.

I know that openpyxl and xlrd have the ability to load workbooks, get the sheet names and then loop through them. Does either of these modules have the ability to grab the sheet color or is there another library that can handle my intended scenario?

Below is some code I have been playing around with ..

# from openpyxl import load_workbook

# workbook = load_workbook(filename='TestRateFile.xlsx', read_only=True)
# sheets = workbook.sheetnames

# for s in sheets:
    # print(s)

import xlrd
loc = ('InXLS.xls')

wb = xlrd.open_workbook(loc, formatting_info=True)
sheets = wb.sheet_names()

for index, sh in enumerate(sheets):
    print(sh)

Below is the snippet I took of the workbook sheets

https://imgur.com/a/8Kdha8P
Unfortunately, the named_styles approach did not work :(