如何迭代多行和多列而不是一列?

时间:2017-11-07 12:57:08

标签: python excel python-3.x excel-2010 openpyxl

我的工作只迭代第一行,并在一列中显示数据。我试图通过迭代所有行来通过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')

0 个答案:

没有答案