'MergedCell' object attribute 'comment' is read-only
Created originally on Bitbucket by piotrdab_ (Piotr Dąbrowski)
I have a problem with opening some file. Trying to open it with read_only=True
finishes without any problems, but I need to have an info whether a cell/row/column is hidden and currently don't see any other way than to load the file with read_only=False
. I've stripped any unnecessary for this issue content from the file and attached as a test_file.xlsx
. The file contain only one merged cell and does not open properly.
In [1]: from openpyxl import load_workbook
In [2]: load_workbook('/home/piotr/Desktop/test_file.xlsx')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-48edaf6f6504> in <module>
----> 1 load_workbook('/home/piotr/Desktop/test_file.xlsx')
~/miniconda3/envs/openpyxl/lib/python3.7/site-packages/openpyxl/reader/excel.py in load_workbook(filename, read_only, keep_vba, data_only, keep_links)
310 reader = ExcelReader(filename, read_only, keep_vba,
311 data_only, keep_links)
--> 312 reader.read()
313 return reader.wb
~/miniconda3/envs/openpyxl/lib/python3.7/site-packages/openpyxl/reader/excel.py in read(self)
272 self.read_theme()
273 apply_stylesheet(self.archive, self.wb)
--> 274 self.read_worksheets()
275 self.parser.assign_names()
276 if not self.read_only:
~/miniconda3/envs/openpyxl/lib/python3.7/site-packages/openpyxl/reader/excel.py in read_worksheets(self)
233 comment_sheet = CommentSheet.from_tree(fromstring(src))
234 for ref, comment in comment_sheet.comments:
--> 235 ws[ref].comment = comment
236
237 # preserve link to VML file if VBA
AttributeError: 'MergedCell' object attribute 'comment' is read-only
In [4]: openpyxl.__version__
Out[4]: '2.6.2'
Attachments: test_file.xlsx