Python 读取xlsx文件

2019/8/27 posted in  工具

安装 openpyxl

pip3 install openpyxl

示例

 from openpyxl import load_workbook
 
workbook = load_workbook('strings3.xlsx')
#booksheet = workbook.active                #获取当前活跃的sheet,默认是第一个sheet
booksheet = workbook['Sheet 1']
 
rows = booksheet.rows
columns = booksheet.columns
#迭代所有的行
for row in rows:
    line = [col.value for col in row]
    print(line)

参考