Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Openpyxl auto-height row

I'm trying to set wrap text. But when i using wrap text row doesn't change height automatically. How can I set auto-height row?

like image 230
APatrikMs94 Avatar asked Jun 17 '16 22:06

APatrikMs94


2 Answers

You need to look at the RowDimension object for the relevant row, specifically the height attribute:

rd = ws.row_dimensions[3] # get dimension for row 3
rd.height = 25 # value in points, there is no "auto"
like image 175
Charlie Clark Avatar answered Nov 06 '22 10:11

Charlie Clark


You can use row_dimensions or column_dimensions property to set height or width:

# set the height of the row 
sheet.row_dimensions[1].height = 20
  
# set the width of the column 
sheet.column_dimensions['B'].width = 20
like image 6
Vlad Bezden Avatar answered Nov 06 '22 10:11

Vlad Bezden