Python中是否有方法比较不同行中的Excel单元格,如果单元格不同,则插入一行? 以下是迄今为止我对python代码的了解:
filename2 = "myfile.xlsx."
wb2 = xl.load_workbook(filename2)
ws2 = wb2.active
mr2 = ws2.max_row
#here is where I compare the cells and insert a row if it does not match
for i in range(2, mr + 1):
if ws2.cell(row=i, column=2).value != ws2.cell(row=i + 1, column=2).value:
ws2.insert_rows(idx= i + 1)
wb2.save(str(filename2))
目前没有回答
相关问题 更多 >
编程相关推荐