2

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?

wovano
  • 4,543
  • 5
  • 22
  • 49
00noob
  • 152
  • 1
  • 10

1 Answers1

1

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.

wovano
  • 4,543
  • 5
  • 22
  • 49
botenvouwer
  • 4,334
  • 9
  • 46
  • 75