Reputation: 498
I cannot figure out how to apply a row height on an existing worksheet unless I do it one row at a time.
This works for a single row:
ws4.row_dimensions[14].height = 25
But I want to set the row height for row 7 and any subsequent rows.
This approach does nothing yet does not throw an error:
for rows in ws4.iter_rows(min_row=7, max_row=None):
ws4.row_dimensions.height = 25
wb4.save('C:\\folder\\DataplusRows.xlsx')
Any idea how to do this? I can't glean the answer from the openpyxl documentation. And I can't seem to find examples anywhere.
Upvotes: 1
Views: 5179
Reputation: 15513
Comment: There must be something in my sheet preventing me from setting the row height.
Tested with existing Workbook, load_workbook(...
,
the Rows 4 - 6
set to .height = 48
, are shown OK.
Relevant:
Question: Applying row height to all rows including and after row 7
Note: Test
Workscheet
has 6 Rows, starting at Row 4.
import openpyxl
wb = openpyxl.Workbook()
ws = wb.active
for _ in range(6):
ws.append(('TEST' for _ in range(4)))
for row in range(4, ws.max_row + 1):
ws.row_dimensions[row].height = 48
# wb.save(...)
Upvotes: 5