1 To understand first excel The structure of the table
workbook xls– Worksheet sheet– Cell cell
2 install xlrd package
stay window Environment shortcut win+R Input cmd
stay cmd Interface input pip install xlrd==1.2.0
The successful installation interface goes to the next page
C:\Users\g>pip install xlrd==1.2.0
Defaulting to user installation because normal site-packages is not writeable
Collecting xlrd==1.2.0
Using cached xlrd-1.2.0-py2.py3-none-any.whl (103 kB)
Installing collected packages: xlrd
Successfully installed xlrd-1.2.0
3 Create a excel workbook , Workbook name New table
Enter values in the first table of the workbook hello
python Code in
import xlrd # Import xlrd package
xlsx = xlrd.open_workbook(r'D:\ New table .xlsx') # Open the workbook New table .xlsx
table = xlsx.sheet_by_index(0) # Open first sheet
print(table.cell_value(0,0)) # Print page 1 That's ok 1 The value of the column
Output results
"C:\Program Files\Python37\python.exe" D:/PycharmProjects/pythonProject_excle/excel_xlrd.py
hello
Process finished with exit code 0