Python openpyxl write list to Excel error

允我心安 提交于 2019-12-04 10:00:05

Instead of assigning the value of each cell to masterList1, you probably meant to use the masterList1[rowNum] as a value:

for rowNum in range(2, len(masterList1)):
    destSheet.cell(row=rowNum, column=1).value = masterList1[rowNum]

Plus, as @mgrant pointed out, you should've extended (not appended) the master list previously:

masterList1.extend(newList1)

Have you tried using extend instead of append? append adds a single item to the end of a list, whereas extend takes a list argument and adds each item.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!