Unprotect an Excel file programmatically

后端 未结 4 843
我在风中等你
我在风中等你 2020-12-09 14:19

We\'re getting an Excel file from a client that has open protection and Write Reserve protection turned on. I want to remove the protection so I can open the Excel file wit

4条回答
  •  情深已故
    2020-12-09 15:03

    This function works for me

    def Remove_password_xlsx(filename, pw_str):
        xcl = win32com.client.Dispatch("Excel.Application")
        wb = xcl.Workbooks.Open(filename, False, False, None, pw_str)
        xcl.DisplayAlerts = False
        wb.SaveAs(filename, None, '', '')
        xcl.Quit()
    

提交回复
热议问题