def xls_xlsx(PathName):
excel = win32com.client.DispatchEx('Excel.Application')
excel.DisplayAlerts = 0
wb = excel.Workbooks.Open(PathName)
wb.SaveAs(PathName + "x", FileFormat=51)
wb.Close()
excel.DisplayAlerts = 1
excel.Application.Quit()
It depends on what you want. If Excel is already open, using dispatch will create a new tab in the open Excel instance. If Excel is already open, using dispatchEx will open a new instance of Excel.
Dispatch 如果已经打开 excel,就在当前的excel中开一个新标签
DispatchEx 如果已经打开 excel,另外开一个excel实例