{"id":15,"date":"2026-01-25T11:56:29","date_gmt":"2026-01-25T03:56:29","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=15"},"modified":"2026-01-17T04:32:47","modified_gmt":"2026-01-17T04:32:47","slug":"how-to-set-row-height-and-column-width-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-set-row-height-and-column-width-using-xlwings\/","title":{"rendered":"How To Set Row Height and Column Width Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<h3 style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\"><span style=\"font-weight: bold;\">Row height<\/span><\/h3>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#xlwings API<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">sht.api.Rows(3).RowHeight = 30<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;C5&#8217;).EntireRow.RowHeight = 40<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;C5&#8217;).RowHeight = 40<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Cells.RowHeight = 30<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 8.0pt;\">\n<h3 style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\"><span style=\"font-weight: bold;\">Column width<\/span><\/h3>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Columns(2).ColumnWidth = 20<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;C4&#8217;).ColumnWidth = 15<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;C4&#8217;).EntireColumn.ColumnWidth = 15<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Cells.ColumnWidth = 10<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Setting Row Heights and Column Widths\n\nimport xlwings as xw    #Import the xlwings package\n\napp=xw.App()\nbk=app.books.active    #Get the active workbook\nsht=bk.sheets.active    #Get the active worksheet\n\n#Row height\n#xlwings API\nsht.api.Rows(3).RowHeight = 30\n#sht.api.Range('C5').EntireRow.RowHeight = 40\n#sht.api.Range('C5').RowHeight = 40\n#sht.api.Cells.RowHeight = 30\n\n#Column width\nsht.api.Columns(2).ColumnWidth = 20\n#sht.api.Range('C4').ColumnWidth = 15\n#sht.api.Range('C4').EntireColumn.ColumnWidth = 15\n#sht.api.Cells.ColumnWidth = 10\n\n#bk.close()\n#app.kill()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"883\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/01\/2.png\" alt=\"Set Row Height and Column Width Using xlwings\" class=\"wp-image-240\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/01\/2.png 883w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/01\/2-300x164.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/01\/2-768x419.png 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Method<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-xlwings-worksheet"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":3,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}