0

I am unsure as to what the below means from the OpenPyXL documentation:

Styles can also applied to columns and rows but note that this applies only to cells created (in Excel) after the file is closed. If you want to apply styles to entire rows and columns then you must apply the style to each cell yourself. This is a restriction of the file format:'

I'm unsure what this applies only to cells created (in Excel) after the file is closed means.

>>> col = ws.column_dimensions['A']
>>> col.font = Font(bold=True)
>>> row = ws.row_dimensions[1]
>>> row.font = Font(underline="single")

I tried the below code to change row 4's font but it isn't having any impact.

row = ws.row_dimensions[4]
row.font = Font(name='Arial', size=8)

Is there a solution instead of changing every individual cell?

Thanks

Beniamin H
  • 1,977
  • 1
  • 9
  • 17
  • Does this answer your question? [Alter the style of all cells with openpyxl](https://stackoverflow.com/questions/23830938/alter-the-style-of-all-cells-with-openpyxl) – Paul Brennan Jan 05 '21 at 22:27
  • 1
    I ran the solution and ran into the error `AttributeError: 'Worksheet' object has no attribute '_styles'`. It's also almost 7 years old so I thought an updated solution may have been created. – Tickets2Moontown Jan 05 '21 at 22:51

0 Answers0