To see how to extract data from an excel file using python3.
The openpyxl module allows Python program to read and modify Excel files.
Its the open source library designed with python.
We can read, write, rename , merge data using this module.
#import openpyxl module
import openpyxl
#create workbook object
wb=openpyxl.load_
workbook(‘Employee.xlsx’)
#data extract from sheet1
sheet=(wb[‘Sheet1’])
#take a data from a cell
a=sheet[‘B2’]
print(a.value)
print(a.column)
print(a.row)
b=sheet.cell(row=5,column=3)
print(b.value)
print(b.column)
print(b.row)
print(“\n”)
#reading entire row
print(“Reading whole row with Openpyxl\n”)
for c in range(1,7):
d=sheet.cell(row=3,column=c)
print(d.value)
print(“\n”)
#reading entire column
print(“Reading whole column with Openpyxl\n”)
for r in range(1,12):
d=sheet.cell(row=r,column=2)
print(d.value)