top of page
back.jpg

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
    print()

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...

 
 
 

Kommentare

Mit 0 von 5 Sternen bewertet.
Noch keine Ratings

Rating hinzufügen
  • Facebook
  • Twitter
  • LinkedIn

©2019 by MGNK Junction - Junction to uplift your life

bottom of page