import os
import xlwings as xw
import pandas as pd
app = xw.App(visible=True, add_book=False)
file_path = r'd:\python_file\产品销售统计表'
file_list = os.listdir(file_path)
for i in file_list:
if os.path.splitext(i)[1] == '.xlsx':
workbook = app.books.open(file_path + '\\' + i)
worksheet= workbook.sheets
for j in worksheet:
values = j.range('a1').expand('table').options(pd.DataFrame).value
max = values['销售利润'].max()
min = values['销售利润'].min()
j.range('j1').value = '最大销售利润'
j.range('j2').value = max
j.range('k1').value = '最小销售利润'
j.range('k2').value = min
workbook.save()
workbook.close()
app.quit()
C6.11 批量统计工作簿的最大值与最小值
最新推荐文章于 2024-06-12 20:55:45 发布