编程语言
首页 > 编程语言> > python读取xlsx文件

python读取xlsx文件

作者:互联网

import openpyxl
#打开excel文件,获取工作簿对象
dog_food = openpyxl.load_workbook('dog-food.xlsx')
#从工作薄中获取一个表单(sheet)对象
sheets = dog_food.sheetnames
print(sheets, type(sheets))
sheet1 = dog_food['Sheet1']
col_range = sheet1['A:B']
demand = []
for col in col_range: # 打印AB两列单元格中的值内容
    for cell in col:
        print(cell.value)

标签:xlsx,读取,python,dog,cell,food,sheet1,sheets,col
来源: https://blog.csdn.net/weixin_43464554/article/details/114382493