top of page

Read data From Excel Python

import openpyxl

# Load the Excel workbook
workbook = openpyxl.load_workbook("C://Users/Nikil/PycharmProjects/pythonBasics/Userdata.xlsx")

# Access the specified sheet by name (using workbook[sheet_name])
sheet = workbook["Sheet1"]

# Get the number of rows and columns in the sheet
rows = sheet.max_row
columns = sheet.max_column
print("Number of rows:", rows)
print("Number of columns:", columns)

# Iterate through each row and column to print cell values
for r in range(2, rows + 1):  
# Start from the second row (assuming headers in the first row)
    for c in range(1, columns + 1):
        # Print the value of each cell, separated by spaces
        print(sheet.cell(row=r, column=c).value, end="      ")
# Move to the next line after printing values of all columns in the current row

1 view0 comments

Recent Posts

See All

Test case for Valid Coupon Code

This test case checks whether a valid coupon code is successfully applied to a booking cart, the total is updated accordingly, and a success message is displayed. package com.seleniumExamples2024; pu

Keyboard shortcut keys for various operations

General Shortcuts: Ctrl + C: Copy Ctrl + X: Cut Ctrl + V: Paste Ctrl + Z: Undo Ctrl + Y: Redo Ctrl + A: Select All Ctrl + S: Save Ctrl + P: Print Ctrl + F: Find Windows Shortcuts: Windows Key: Open or


Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page