Xlwings / open password protected worksheet in xlsx?

2024/11/15 9:20:50

I get an answer how to open a password protected xlsx with xlwings: Xlwings / open password protected xlsx?

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

But can i also open and handle a worksheet in an xlsx - where only this specific worksheet of the xlsx is password-protected and not the whole xslx? Or the xlsx is only password-protected for writing (and reading is allowed)?

I tried this with the solution from the above link but this didn´t work for the situations as desccribed above.

Answer

'Protect Sheet'.

ws.api.Protect(Password='test')
ws.api.Unprotect(Password='test')

Other features under this setting (not full tested);

ws.api.Protect(Password='test', DrawingObjects=True, Contents=True, Scenarios=True,UserInterfaceOnly=False, AllowFormattingCells=False, AllowFormattingColumns=True,AllowFormattingRows=False, AllowInsertingColumns=False, AllowInsertingRows=False,AllowInsertingHyperlinks=False, AllowDeletingColumns=False, AllowDeletingRows=False,AllowSorting=False, AllowFiltering=False, AllowUsingPivotTables=False)
https://en.xdnf.cn/q/119440.html

Related Q&A

Wrapping an opencv implementaion of an error level analysis algorithm using cython

i have implemented an error level analysis algorithm using c++(opencv version 2.4) and i want to build a python wrapper for it using cython. I have read some part of the documentation of cython for c++…

Setting yticks Location Matplotlib

Im trying to create a plot which has y axis exactly same with this : And Im in this situation and everything is ok until this point:When i try this lines:ax.set_yticks(range(20,67,10)) ax.set_yticklabe…

How to merge list to become string without adding any character in python?

I found that I can join them with -.join(name) but I dont want to add any character. Lets say I have [stanje1, |, st6, , stanje2, |, #] and I want to be like thisstanje1|st6,stanje2|#

Removing a key from a nested dictionary based on value

I previusly asked about adding, and someone helped me out with append. My new problem is trying to delete a key with a nested list, e.g.:JSON:data = {"result":[{"name":"Teddy&q…

Is dot product and normal multiplication results of 2 numpy arrays same?

I am working with kernel PCA in Python and I have to find the values after projecting the original data to the principal components.I use the equation fv = eigvecs[:,:ncomp]print(len(fv))td = fv.T …

Tkinter Entry widget stays empty in larger programs (Python 2)

I want to make a program where, after clicking on a button, a user gets asked for its name, after which the program continues. Im stuck on making the popup return the textstring that has been entered i…

How do i implement this python tree linked list code in dart?

Here is the python codedef tree(root_label, branches=[]):for branch in branches:assert is_tree(branch), branches must be treesreturn [root_label] + list(branches)def label(tree):return tree[0]def branc…

How can i find the ips in network in python

How can i find the TCP ips in network with the range(i.e 132.32.0.3 to 132.32.0.44) through python programming and also want to know the which ips are alive and which are dead. please send me.. thanks …

Python Coding (call function / return values)

I am having trouble writing code for this question. I have seen this question asked in a few places but I still cannot figure out the answer from the tips they provided. The question is: Write a progr…

discord.py Mention user by name

I am trying to mention a user by their name in discord.py. My current code is: @bot.command(name=mention) @commands.has_role(OwnerCommands) async def mention(ctx, *, member: discord.Member):memberid = …