import win32com.client
import time
path = r'absolute dir' #比如填文件的绝对路径,比如d:/file/stock.xlsx
xl = win32com.client.DispatchEx("Excel.Application")
workbook = xl.Workbooks.Open(path)
xl.Visible = False
workbook.RefreshAll()
workbook.Save()
# time.sleep(3) #如果文件足够大,那么最好是在关闭excel之前保持几秒钟
workbook.Close(True)
xl.Quit()

from: https://blog.csdn.net/chang1976272446/article/details/80668034

05-11 21:57