How to read xlsx color information using openpyxl

I am using openpyxl to read an excel file.

For my application, I need to read the background color of the cell in the xlsx file, but I cannot find how to load the color information.

I tried using cell.style.fill.color.index, but it returns FFFFFFFF as a background that does not match the file I read.

Does openpyxl support reading in color format?

+5
source share
1 answer

UPDATE (2014):

I renewed until v. 2.2. They seem to have solved the problem that I fixed in my original answer (see below). Now I can successfully get the background color after I set it manually through Excel. However, the syntax has changed a bit:

somecell.fill.start_color.index

ORIGINAL RESPONSE (2012):

, openpyxl :

_cell.style.fill.fill_type = Fill.FILL_SOLID
_cell.style.fill.start_color.index = Color.DARKGREEN

, :

_style.fill.start_color.index

:

'FF008000'

, Excel , openpyxl, , :

'FFFFFFFF'

, , opepyxl - . . , , openpyxl.

+6

All Articles