vlookup也可以,就是俩excel表有几列数据,找到一样的。首先把俩excel的内容粘到一个excel里,然后遍历表a中的3列数据,和表b的3列数据做对比,一样的数据就标记出来
from openpyxl import workbook
from openpyxl import load_workbook
if __name__ == "__main__":
excel=load_workbook('明细表汇总(1).xlsx')
ws=excel['Sheet2']
for i in range(614):
b=i+1
for j in range(8718):
a=j+1
if (ws.cell(b,4).value == ws.cell(a,1).value and ws.cell(b,5).value == ws.cell(a,2).value and ws.cell(b,6).value == ws.cell(a,3).value):
print(ws.cell(a,2).value)
if ws.cell(a,8).value==None:
ws.cell(a,7).value=b
ws.cell(a,8).value="重复"
elif ws.cell(a,8).value != None:
ws.cell(a,7).value=str(ws.cell(a,7).value)+"和"+str(b)+"重复"
excel.save('明细表汇总(1).xlsx')