Method
Row height
#xlwings API
sht.api.Rows(3).RowHeight = 30
#sht.api.Range(‘C5’).EntireRow.RowHeight = 40
#sht.api.Range(‘C5’).RowHeight = 40
#sht.api.Cells.RowHeight = 30
Column width
#sht.api.Columns(2).ColumnWidth = 20
#sht.api.Range(‘C4’).ColumnWidth = 15
#sht.api.Range(‘C4’).EntireColumn.ColumnWidth = 15
#sht.api.Cells.ColumnWidth = 10
Sample Code
#Setting Row Heights and Column Widths
import xlwings as xw #Import the xlwings package
app=xw.App()
bk=app.books.active #Get the active workbook
sht=bk.sheets.active #Get the active worksheet
#Row height
#xlwings API
sht.api.Rows(3).RowHeight = 30
#sht.api.Range('C5').EntireRow.RowHeight = 40
#sht.api.Range('C5').RowHeight = 40
#sht.api.Cells.RowHeight = 30
#Column width
sht.api.Columns(2).ColumnWidth = 20
#sht.api.Range('C4').ColumnWidth = 15
#sht.api.Range('C4').EntireColumn.ColumnWidth = 15
#sht.api.Cells.ColumnWidth = 10
#bk.close()
#app.kill()

Leave a Reply