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()
top of page
MGNK Junction
Recent Posts
See AllThis test case checks whether a valid coupon code is successfully applied to a booking cart, the total is updated accordingly, and a...
160
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 +...
50
bottom of page
Comments