操作excel

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")          #保存

 

posted @ 2023-06-15 16:46  *飞飞*  阅读(6)  评论(0编辑  收藏  举报