123456789101112131415161718192021 |
- import os
- import win32com.client
- def convert(path: str):
- excel_com = win32com.client.Dispatch("Excel.Application")
- excel_com.DisplayAlerts = False
- for file in filter(lambda x: x.endswith(".xls"), os.listdir(path)):
- print(file)
- fullname = path + "\\" + file
- excel_com.Workbooks.Open(fullname)
- excel_com.ActiveWorkbook.SaveAs(
- Filename=fullname + "x", ConflictResolution=True
- )
- excel_com.ActiveWorkbook.Close(True)
- if __name__ == "__main__":
- path = os.getcwd() + "\\Excel"
- convert(path)
|