The previously used win32com read the relevant content with password Excel, today just ready to tidy up, suddenly found that the method is not the spirit.
The following is a demonstration of the error:
# known Excel password removal def del_password (filename, password): Excel = Dispatchex ("Excel.Application") # Start Excel Excel. Visible = True # visual Excel. DisplayAlerts = False # whether to display warning WB = Excel. Workbooks.Open (filename, Password=password) # Open File
This is magical, before the use of good? , no reason ah so simple to open, do not add a password parameter? Clearly the password parameters to input, why also prompted to enter the password box?
(look again at the official introduction of Microsoft BB)Https://msdn.microsoft.com/zh-cn/VBA/Excel-VBA/articles/workbooks-open-method-excel, No problem.
Not really, back to the previous write. Think of a problem, we pay attention to different, pay attention to add a few parameters.
(The standard red parameter is not one, the order does not affect, but there is no real connection between these parameters ah, baffled. Before Mark, there is the idea of the great God--have encountered a similar method before to write only one parameter can not, if there is a similar situation try to write the parameters of the full operation.
For the time being only one conclusion: the win32com read Excel operation is not strictly in accordance with the Python positional parameters, not dispensable, but strictly match.
—————————— Split Line ————————————
The following are correct
# known Excel password removal def del_password (filename, password): Excel = Dispatchex ("Excel.Application") # Start Excel Excel. Visible = visible # visual Excel. DisplayAlerts = DisplayAlerts # whether to show warning updatelinks=false, Readonly=false, Format=none, Password=password, Writerespassword=password) # Open File
Python win32com reading Excel with a password