Python win32com reading Excel with a password

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.