Using openpyxl to find rows that contain cell with specific value (Python 3.6)

前端 未结 4 2204
春和景丽
春和景丽 2021-02-10 16:24

I am completely new to openpyxl so, as you can imagine, I am having pretyy hard times when I try to make use of it.

I have an excel report that contains only one sheet

4条回答
  •  终归单人心
    2021-02-10 17:07

    from openpyxl import load_workbook
    
    wb = load_workbook("report.xlsx")
    ws = wb.active
    
    for row in ws.rows:
    if row[4].value == "ABC":
        for cell in row:
            print(cell.value, end=" ")
        print()
    

提交回复
热议问题