Reputation: 312
I would like to change the row and column height using Openpyxl. I can change the specific row and height like this:
import openpyxl
wb = openpyxl.Workbook()
ws = wb.active
ws.row_dimensions[1].height = 10
But I want to change the default height and width of rows and column so that I don't have to do this for each row and each column.
Is it possible to do this?
Upvotes: 3
Views: 1724
Reputation: 4432
According to this piece of Microsoft documentation, you can have 1,048,576 rows and 16,384 columns. I searched in openpyxl to find a way to set default column width but could not find a way, even though this is possible in Excel. I guess the openpyxl does not provide an interface to set this.
You could create a ticket here to request such a feature. However you can also just set the maximum of columns yourself:
for i in range(1, 16384):
worksheet.column_dimensions[get_column_letter(i)].width = 1.89
You can do the same thing for the height.
Upvotes: 2