How To Reference General Cell Ranges Using xlwings?

Method

#xlwings

sht.range(‘A3:C8’).select()    #Select the cell range A3:C8

#sht.range(‘A3′,’C8’).select()

#sht.range(sht.range(‘A3’),sht.range(‘C8’)).select()

#sht.range(sht.cells(3,1),sht.cells(8,3)).select()

#sht.range((3,1),(8,3)).select()

 

#xlwings API

#sht.api.Range(‘A3:C8’).Select()

#sht.api.Range(‘A3′,’C8’).Select()

#sht.api.Range(sht.api.Range(‘A3’), sht.api.Range(‘C8’)).Select()

#sht.api.Range(sht.api.Cells(3,1),sht.api.Cells(8,3)).Select()

Sample Code

#Referencing a General Range of Cells

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

#xlwings
sht.range('A3:C8').select()    #Select the cell range A3:C8
#sht.range('A3','C8').select()
#sht.range(sht.range('A3'),sht.range('C8')).select()
#sht.range(sht.cells(3,1),sht.cells(8,3)).select()
#sht.range((3,1),(8,3)).select()

#xlwings API
#sht.api.Range('A3:C8').Select()
#sht.api.Range('A3','C8').Select()
#sht.api.Range(sht.api.Range('A3'), sht.api.Range('C8')).Select()
#sht.api.Range(sht.api.Cells(3,1),sht.api.Cells(8,3)).Select()

#bk.close()
#app.kill()
Reference General Cell Ranges Using xlwings
January 28, 2026 (0)


Leave a Reply

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