Reputation: 559
I can add custom style using NamedStyle from openpyxl. Is there any way to get existing custom styles and remove using openpyxl?
Upvotes: 3
Views: 1742
Reputation: 131
I ran into this issue as well so I hacked until this worked. I used the _named_styles , which isn't exactly best practice, but it gets the job done.
I used list comp returning index from an index value lookup
del wb._named_styles[ wb.style_names.index('yourstyle')]
I put this additional check to make certain its present before deleting
if a_style in wb.named_styles:
del wb._named_styles[ wb.style_names.index(a_style)]
Upvotes: 2
Reputation: 1
Hi it seems like you can use workbook.named_styles
to get style list.
This will return a list including all style exist.
Upvotes: 0