Conditional Formatting Rule() undefined

127 views
Skip to first unread message

Ryan Ma

unread,
Nov 6, 2017, 7:55:46 PM11/6/17
to openpyxl-users
Hello,
I am relatively new to coding. I want to automate one of the reports i run at work since it takes about 10-15 minute of my time a day
I am getting undefined name 'Rule' error when i type in the highlighted in to my IDE. Essentially what im trying to do is if the cell
in COL D has the word 'PEFI' highlight that COL orange. 
#format for LDC Status to highlight accounts going final

orange_fill = PatternFill(bgColor='ffbb4f')
black_text = Font(color='000000')
dxf = DifferentialStyle(font=black_text, fill=OrangeFill)
rule = Rule(type='containsText',operator='containsText', text='PEFI',dxf=dxf)
rule.formula = ['NOT(ISERRROR(SEARCH("PEFI",D1)))']
ws.conditional_formatting.add('D:D',rule)
Please let me know why im getting this error. Im basing my formatting off the example on the conditional formatting examples given on the webpage.
also if anyone has an example where i can mirror the conditional formatting for finding text it would be greatly appreciated!

Thanks
Ryan

John Serrano

unread,
Mar 31, 2022, 6:19:05 PM3/31/22
to openpyxl-users
Hi Ryan,
What IDE did you use in 2017 and what IDE would you recommend for openPYXL in 2022?
Thank you,
John Serrano

Charlie Clark

unread,
Apr 1, 2022, 3:29:42 AM4/1/22
to openpyxl-users
On 1 Apr 2022, at 0:19, John Serrano wrote:

> Hi Ryan,
>
> What IDE did you use in 2017 and what IDE would you recommend for openPYXL
>
> in 2022?

Personally, I use WingIDE and would recommend it for Python but IDE's can be a very personal choice.

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