from openpyxl import Workbook from openpyxl import load_workbook wb= load_workbook(u"projects-shanghai.xlsx") ws = wb.worksheets[0] maxRow = ws.max_row #获取总行数 print('#excleRowSum: '+str(maxRow)) for i in range(2,maxRow+1): if ws.cell(row=i,column=exlID['xmID']).value == xmInfo[xmInfoID['xmID']]: #判断要写入的数据在excel中第几行 print('#actualRow: '+str(i)) ws.cell(row=i,column=exlID['hitCompany']).value = xmInfo[xmInfoID['hitCompany']] #写入数据 wb.save(u"projects-shanghai.xlsx") #保存
标签:load,wb,excel,maxRow,ws,操作,row From: https://www.cnblogs.com/feifeidxl/p/17483381.html