程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

How to read the value in Excel cell with Python

編輯:Python

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

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved