Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear the entire workbook's conditional formatting by openpyxl

I wrote some code to do the conditional formatting. However, whenever I run the code, the cell are written with same conditional formatting once. Is there any way to clear the existing ones and write the new.

I have checked the offical documentation https://openpyxl.readthedocs.io/en/stable/formatting.html but no clear function inside

like image 337
Rick Zhang Avatar asked Oct 20 '25 15:10

Rick Zhang


1 Answers

If you just want to clear the formatting for a particular worksheet you just need to create a new list:

from openpyxl.formatting.formatting import ConditionalFormattingList
ws.conditional_formatting = ConditionalFormattingList()
like image 78
Charlie Clark Avatar answered Oct 23 '25 06:10

Charlie Clark