利用python脚本批量读取当前目录下所有excle表格中特定的单元格内容
import os
from openpyxl import load_workbook
# 设置要读取的单元格地址
cell_address = 'N18'
# 遍历当前目录下的所有文件
for filename in os.listdir('.'):
if filename.endswith('.xlsx'):
# 加载工作簿
workbook = load_workbook(filename)
# 假设我们总是读取第一个工作表
sheet = workbook.active
# 读取特定单元格的值
value = sheet[cell_address].value
print(f"File: {filename}, Cell N18: {value}")
标签:读取,当前目录,python,单元格,filename,workbook,excle From: https://www.cnblogs.com/hkgan/p/18196391