[英]how to read/open password protected xlsx file in python
ive successfully decrypted xlsx file using cmd = "msoffcrypto-tool hello.xlsx decrypted.xlsx -p erh1"
os.system(cmd)
我使用
cmd = "msoffcrypto-tool hello.xlsx decrypted.xlsx -p erh1"
os.system(cmd)
成功解密了 xlsx 文件
but when i open the decrypted.xlsx using wb = load_workbook(inputFilePath, data_only=True)
但是当我使用
wb = load_workbook(inputFilePath, data_only=True)
打开decrypted.xlsx
i get few warnings and and errors but it opens fine, i want to remove these errors我收到很少的警告和错误,但它打开得很好,我想删除这些错误
File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/descriptors/base.py", line 55, in _convert value = expected_type(value) ValueError: could not convert string to float: '(#REF!-40)' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/worksheet/_reader.py", line 280, in parse_formatting cf = ConditionalFormatting.from_tree(element) File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/descriptors/serialisable.py", line 87, in from_tree obj = desc.expected_type.from_tree(el) File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/descriptors/serialisable.py", line 87, in from_tree obj = desc.expected_type.from_tree(el) File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/descriptors/serialisable.py", line 87, in from_tree obj = desc.expected_type.from_tree(el) File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/descriptors/serialisable.py", line 103, in from_tree return cls(**attrib) File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/formatting/rule.py", line 57, in __init__ self.val = val File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/formatting/rule.py", line 36, in __set__ super(ValueDescriptor, self).__set__(instance, value) File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/descriptors/base.py", line 67, in __set__ value = _convert(self.expected_type, value) File "/home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/descriptors/base.py", line 57, in _convert raise TypeError('expected ' + str(expected_type)) TypeError: expected <class 'float'> warn(msg) /home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/worksheet/_reader.py:300: UserWarning: Data Validation extension is not supported and will be removed warn(msg) /home/muhammadu/.local/lib/python3.8/site-packages/openpyxl/worksheet/_reader.py:300: UserWarning: Conditional Formatting extension is not supported and will be removed warn(msg)
or is there any other way to decrypt xlsx using python?还是有任何其他方法可以使用 python 解密 xlsx? i used
msoffcrypto-tool
我使用
msoffcrypto-tool
If you have a line that starts with xlwb
, you should ensure that you have the proper code after it.如果您有一行以
xlwb
,则应确保在其后有正确的代码。
To open a protected file, you should have:要打开受保护的文件,您应该:
xlwb = xlApp.Workbooks.Open(filename, False, True, None, password)
That should hopefully work.这应该会奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.