1

I have xlsx file with some values and I am trying to get the color.index from each cell in this document. The problem is:

If cell's color is picked from Styles menu in Excel (for example: 'Bad', 'Good' etc..) the color.index value is 'C6EFCE' which is perfect value and I can used it later. But if cell's color is just picked from 'Theme colors' menu in Excel the color.index value is something like: 5L, 11L etc...

I know that there is styles.colors.COLOR_INDEX list with colors and their indexes, but when I search color by index it gives me different color than used one in the document.

I noticed that if I modify some of preset styles in Excel and change its color, and use this style for cells, when I execute the script it recognized the color, but this means that every time I need to modify one of the Styles and this does not satisfy me.

from openpyxl import load_workbook, styles

wb= load_workbook('My_file.xlsx')
ws= wb['Sheet1']

print(ws['A1'].fill.start_color.index)
unreax
  • 11
  • 3
  • Is [this question](https://stackoverflow.com/questions/32736419/get-cell-color-from-xlsx) helpful? – BigBen Dec 03 '19 at 15:01
  • [This](https://stackoverflow.com/questions/58429823/getting-excel-cell-background-themed-color-as-hex-with-openpyxl) helped me. – unreax Dec 04 '19 at 11:04

0 Answers0