Cannot open excel file with the "open read-only recommended" flag

Issue #692 closed
tshinbum
created an issue

Hi,

I simply tried this

>>> from openpyxl import load_workbook
>>> w = load_workbook('x1_ro_recomm.xlsx')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\tools\Python27\lib\site-packages\openpyxl\reader\excel.py", line 161, in load_workbook
    parser.parse()
  File "c:\tools\Python27\lib\site-packages\openpyxl\packaging\workbook.py", line 41, in parse
    package = WorkbookPackage.from_tree(node)
  File "c:\tools\Python27\lib\site-packages\openpyxl\descriptors\serialisable.py", line 76, in from_tree
    obj = desc.expected_type.from_tree(el)
  File "c:\tools\Python27\lib\site-packages\openpyxl\descriptors\serialisable.py", line 89, in from_tree
    return cls(**attrib)
  File "c:\tools\Python27\lib\site-packages\openpyxl\workbook\protection.py", line 108, in __init__
    self.userName = userName
  File "c:\tools\Python27\lib\site-packages\openpyxl\descriptors\base.py", line 44, in __set__
    raise TypeError('expected ' + str(self.expected_type))
TypeError: expected <type 'basestring'>

There are some classes which deal with protection, but I was not yet able to find a way how to pass the information about the read-only flag to the load_workbook function.

What I would like to achieve is:

  • detect if a workbook has protection
  • open a protected workbook either read-only or in read-write mode

if it's already possible, i would be thankful about a pointer to the docs.

cheers

Comments (3)

  1. CharlieC

    The error you are seeing has nothing to do with the question you're asking. Please direct questions to the mailing list.

    openpyxl does not support workbook "protection" only the protection of worksheets.

  2. Log in to comment