安装openpyxl

本文使用Python中读取excel包openpyxl,安装 openpyxl

pip install openpyxl   # 或者
conda install openpyxl # 使用 Anaconda IDE

加载excel文件

from openpyxl import load_workbook
wb = load_workbook('test.xlsx')

列出所有excel中所有表:print( wb.get_sheet_names() )

读取数据

读取数据表data

ws = wb['data']

读取单元格数据

c = ws['A4']  #等同于
c = ws.cell(row = 4, column = 1)
print( c.value )

读取spreadsheet区域数据

cell_range = ws['A1':'C2']
for row in cell_range:
	pass

参考文献:openpyxl