How to open a password protected excel file using python?

I reviewed previous topics regarding this topic, but they did not help solve the problem.

I am trying to open a password protected file in excel without any user interaction. I searched the Internet and found this code that uses win32com.client. When I run this, I still get a password prompt ...

from xlrd import *
import win32com.client
import csv
import sys

xlApp = win32com.client.Dispatch("Excel.Application")
print "Excel library version:", xlApp.Version
filename,password = r"\\HRA\Myfile.xlsx", 'caa team'
xlwb = xlApp.Workbooks.Open(filename, Password=password)
+3
source share
2 answers

I don't think named parameters work in this case. So you will need to do something like:

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

Workbooks.Open . http://msdn.microsoft.com/en-us/library/office/ff194819.aspx.

+10

Source: https://habr.com/ru/post/1569329/


All Articles