[Python] How search data in excel with openpyxl?

Discussão em 'Python' iniciado por Stack, Setembro 1, 2025.

  1. Stack

    Stack Membro Participativo

    CODE

    import openpyxl
    wb = openpyxl.open('the path to the file')

    wb.active = 1
    ws = wb.active

    for row in ws.iter_rows('B4:F4'):
    for cell in row:
    if cell.value == "Maria":
    print(ws.cell(row=cell.row, column=2).value)


    Mistake: for row in range(min_row, max_row + 1):

    TypeError: 'str' object cannot be interpreted as an integer

    Excel table

    I need search "Pavel" and print it in console

    Where is the mistake?

    Continue reading...

Compartilhe esta Página