excel.py 442 B

123456789101112131415
  1. import os
  2. import win32com.client
  3. excel = win32com.client.Dispatch('Excel.Application')
  4. excel.DisplayAlerts = False
  5. path = os.getcwd() + '\\Excel'
  6. # def convert(path):
  7. for file in filter(lambda x: x.endswith('.xls'), os.listdir(path)):
  8. print(file)
  9. fullname = path + '\\' + file
  10. excel.Workbooks.Open(fullname)
  11. excel.ActiveWorkbook.SaveAs(Filename=fullname + 'x', ConflictResolution=True)
  12. excel.ActiveWorkbook.Close(True)