我的工作只迭代第一行,并在一列中显示数据。我试图通过迭代所有行来通过openpyxl
删除重复项,但是它不会这样做。我之前使用过Java Apache
,但我们需要迁移到Python
。
wb2 = openpyxl.Workbook('E:/Yeep')
ws2 = wb2.active
wb1 = openpyxl.load_workbook('D:/Yeep.xlsx')
ws1 = wb1.active
values = []
for row in range(ws1.min_row, ws1.max_row):
if ws1.cell(row=row,column=row).value in values:
pass
else:
values.append(ws1.cell(row=row,column=row).value)
directory = 'D:/Yeep.xlsx'
with open(directory, 'a') as outfile:
for value in values:
ws2.append([value])
print(value)
wb2.save('D:/Duplication Complete.xlsx')