Two Ways to Use xlwings

Method

xlwings method, using new syntax

sht.range(‘A1’).value=10

 

xlwings API method, using VBA-style class syntax

sht.api.Range(‘A1’).Value=10

sht.api returns a COM object.

Sample Code

#Two Programming Approaches with the xlwings Package  

import xlwings as xw   #Import the xlwings package 

app=xw.App()    #Create an Excel application
bk=app.books.active    #Get the active workbook
sht=bk.sheets.active    #Get the active worksheet

#xlwings
sht.range('A1').value=10

#xlwings API
#sht.api.Range('A1').Value=10

bk.close()
app.kill()
January 19, 2026 (0)


Leave a Reply

Your email address will not be published. Required fields are marked *