CSSer
CSSer

Reputation: 2587

What is a start_color and end_color in openpyxl

I'm now working on a script that parse xlsx files using python 3 and openpyxl. And I'm confused with the color things.

What is a start_color and end_color of a cell?

I've searched the document but no information was about this.

I can access them with cell.style.fill.start_color, and they give me colors like 'FFFF0000'.

But what do start_color and end_color mean? Why do I need 2 to fill a cell?

Upvotes: 5

Views: 504

Answers (1)

farisfath25
farisfath25

Reputation: 93

It is used for PatternFill as written in the documentation https://openpyxl.readthedocs.io/en/3.1/api/openpyxl.styles.fills.html

class openpyxl.styles.fills.PatternFill(patternType=None, fgColor=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb', bgColor=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb', fill_type=None, start_color=None, end_color=None)

reference: source code

Bases: Fill

start_color
Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

end_color
Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

Area fill patterns for use in styles.
Caution: if you do not specify a fill_type, other attributes will have no effect!

(cc to Charlie Clark above for the hint)

Upvotes: 0

Related Questions