Search code examples
pythonexcelwin32com

Delete all metadata from excel using python


Is there a way to delete all metadata of excel files using python?

It would be preferable to use built-in python libraries such as os or win32com.client


Solution

  • I just solved the issue by using win32com.client

    import win32com.client as win32com    
    book = r'file_path'
    excel = win32com.gencache.EnsureDispatch('Excel.Application')
    wb = excel.Workbooks.Open(book, Local=True)
    wb.RemovePersonalInformation = True
    wb.Close(SaveChanges=1)
    excel.Quit()