Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

openpyxl change background color via parameters

I use openpyxl to create an xlsx file. The contents of the cells are variable depending on certain conditions and each content is associated with a background color.
To avoid having to write so many "font-colors" I thought I’d do something like this:

site_color = color of the condition
cellfont = Font(name='Arial', size=8, bold=False, italic=False, color = %s)%(site_color)

but I get two errors:

"(" was not closed
Expected expression

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Solution:

Set your color parameter directly equal to your site_color.

cellfont = Font(name='Arial', size=8, bold=False, italic=False, color = site_color)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading