Issues with openpyxl not reading all rows in sheet

I cannot get openpyxl to iterate through all the rows I have in an excel notebook.

I am trying to get the code to print all values in a specific column, however, it just iterates over the 500 items and prints the first row 500 times.

This is my code so far:

import pandas as pd
import openpyxl
import requests

wb = openpyxl.load_workbook('search.xlsx')
ws = wb['Results']
df = pd.read_excel (r'search.xls', sheet_name='Results')

for cell in ws:
  y = ws.cell(row=2, column=1)

Edit: Thanks to @topsail, I got the solution:

for row in ws.iter_rows(min_row=2):  

>Solution :

import openpyxl

wb = openpyxl.load_workbook('Search.xlsx')
ws = wb['Result']

for row in ws.iter_rows(min_row=2):
        print("no hyperlink!")

Leave a Reply