Problem with custom Conditional Formatting

19 views
Skip to first unread message

Marta lop seb

unread,
Jun 5, 2024, 3:25:38 PMJun 5
to openpyxl-users
Hello again!

I have a question about how to do a custom Conditional Formatting. I would like to do the following formatting:
- If the no. is negative, I want it to be a green down arrow and the no. green.
- If the number is 0, I want it to be a yellow/orange line and the yellow/orange number.
- If the number is positive, I want it to be a red up arrow and the number red.

How can I do this? I have only found the IconSet but the builtin.

Thank you very much for your help :)

Charlie Clark

unread,
Jun 6, 2024, 5:01:35 AMJun 6
to openpyxl-users

On 5 Jun 2024, at 21:25, Marta lop seb wrote:

Hello again!

I have a question about how to do a custom Conditional Formatting. I would
like to do the following formatting:

  • If the no. is negative, I want it to be a green down arrow and the no.

green.

  • If the number is 0, I want it to be a yellow/orange line and the

yellow/orange number.

  • If the number is positive, I want it to be a red up arrow and the number

red.

How can I do this? I have only found the IconSet but the builtin.

Again, my advice is similar to that for number formats: see what Excel does. Though conditional formats are far from straightforward.

If the existing IconSets are not what you need:

https://openpyxl.readthedocs.io/en/stable/formatting.html#iconset

Then I'm afraid you're out of luck. Microsoft has subsequently introduced additional ones but these require changes to the source code that we're still looking for someone to do or sponsor.

Charlie

--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Sengelsweg 34
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226

Reply all
Reply to author
Forward
0 new messages