How to Open a Password Protected Excel File Using Python

How to open a password protected excel file using python?

I don't think that named parameters work in this case. So you'd have to do something like:

xlwb = xlApp.Workbooks.Open(filename, False, True, None, password)

See http://msdn.microsoft.com/en-us/library/office/ff194819.aspx for details on the Workbooks.Open method.

Xlwings / open password protected xlsx?

xlwings.Book() has a password parameter:

password (str) – Password to open a protected workbook

You should just be able to

import xlwings

wb = xlwings.Book("file.xlsx", password="Passw0rd!")

how to read password protected excel in python

Open takes two types of password, namely:

Password: password required to open a protected workbook.
WriteResPassword : password required to write to a write-reserved workbook

So in your case , is it write protected or protection on open?

Also there is a discussion on SO that says that this does not work with named parameters, So try providing all parameter values with the defaults

  • How to open write reserved excel file in python with win32com?

Default values are documented in MSDN

  • http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open.aspx


Related Topics



Leave a reply



Submit