Openpyxl Formula filling unique row values for entire column

早过忘川 提交于 2019-12-08 13:59:30

From my comment, here is the for-loop code in full:

# n = '=(E2-F2)/C2' # move this assignment into the for-loop

for row, cellObj in enumerate(list(Sheet.columns)[6]):
    print cellObj
    n = '=(E%d-F%d)/C%d' % (row, row, row)
    # print n # check that n gets assigned correct string value
    cellObj.value = n

Hope this helps.

Sander

you have to add +1 at the r(row, row, row).

# n = '=(E2-F2)/C2' # move this assignment into the for-loop

for row, cellObj in enumerate(list(Sheet.columns)[6]):
    print cellObj
    n = '=(E%d-F%d)/C%d' % (row, row, row)
    # print n # check that n gets assigned correct string 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!