How To Write Python List Data to Excel Worksheet Using xlwings?

Method

Write rows

#xlwings

lst=[1,2,3,4,5]

sht.range(‘A1’).value=lst    #Write Python data to Excel worksheet

#Or

#lst=[1,2,3,4,5]

#sht.range(‘E1’).options(transpose=True).value=lst    #Transpose

 

#xlwings API

#lst=[[1],[2],[3],[4],[5]]

#sht.api.Range(‘C1:C5’).Value=lst    #Write directly

#Or

#lst=[1,2,3,4,5]

#sht.api.Range(‘E1:E5’).Value=app.api.WorksheetFunction.Transpose(lst)    #Transpose

 

2D data

#xlwings

#sht.range(‘A5:B6’).value=[[1,2],[3,4]]

#sht.range(‘A1′).options(expand=’table’).value=[[1,2],[3,4]]

 

#xlwings API

#sht.api.Range(‘A5:B6’).Value=[[1,2],[3,4]]

Sample Code

#Write Python list data to Excel worksheet 

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 

#Write rows
#xlwings
#lst=[1,2,3,4,5]
#sht.range('A1').value=lst    #Write Python data to Excel worksheet
#Or
#lst=[1,2,3,4,5]
#sht.range('E1').options(transpose=True).value=lst    #Transpose

#xlwings API
#lst=[[1],[2],[3],[4],[5]]
#sht.api.Range('C1:C5').Value=lst    #Write directly
#Or
#lst=[1,2,3,4,5]
#sht.api.Range('E1:E5').Value=app.api.WorksheetFunction.Transpose(lst)    #Transpose

#2D data
#xlwings
sht.range('A5:B6').value=[[1,2],[3,4]]
sht.range('A1').options(expand='table').value=[[1,2],[3,4]]

#xlwings API
#sht.api.Range('A5:B6').Value=[[1,2],[3,4]]

#bk.close()
#app.kill()
Write Python List Data to Excel Worksheet Using xlwings
February 9, 2026 (0)


Leave a Reply

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