from openpyxl import load_workbook
wb=load_workbook('Project_Python.xlsx')
sheet2=wb.get_sheet_by_name('Sheet2')
sheet3=wb.get_sheet_by_name('Sheet3')
sheet1=wb.get_sheet_by_name('Sheet1')
sheet3=wb.get_active_sheet()
for i in range(3,6369):
d1=(sheet1.cell(row=i,column=1).value)
for j in range(3,6369):
d2=(sheet2.cell(row=i,column=1).value)
if d1==d2:
print(i,sheet1.cell(row=i,column=1).value,"same")
else:
print(i,sheet2.cell(row=i,column=1).value,"modified")
I was comparing two excel sheets i.e sheet1 and sheet2 and i want to display the last 2 outputs in my sheet3 on same workbook. How can i do that?
zip
andws.get_squared_range
as an alternative. – Charlie Clark