Open password protected workbook
Created originally on Bitbucket by ericgazoni (Eric Gazoni)
From KenCorey on the mailing list:
I have an xlsx file that has a password. I can open it in Excel 2007, can access it as normal, etc.
I save it as 'test.xlsx', and make sure that there's no password in the general options of the save as dialog.
Now, when I try to load it according to the tutorial, the problem I get is:
{{{ from openpyxl.reader.excel import load_workbook
wb = load_workbook(filename = r'test.xlsx') Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.6/dist-packages/openpyxl-1.1.7- py2.6.egg/openpyxl/reader/excel.py", line 81, in load_workbook workbook = wb) File "/usr/local/lib/python2.6/dist-packages/openpyxl-1.1.7- py2.6.egg/openpyxl/reader/workbook.py", line 103, in read_named_ranges worksheet_name, column, row = split_named_range(range_string = name_node.text) File "/usr/local/lib/python2.6/dist-packages/openpyxl-1.1.7- py2.6.egg/openpyxl/namedrange.py", line 50, in split_named_range raise NamedRangeException('Invalid named range string') openpyxl.shared.exc.NamedRangeException: Invalid named range string }}}
My machine: linux 2.6.28-19, python 2.6.2, openpyxl installed via easy_install.
Just as a datapoint, if I copy the contents of the spreadsheet, create a new one, and paste the contents into a new sheet, then save that (also making sure there's no password), it opens just fine.
There's something left over from the first sheet having been password protected, apparently.