Bug: load_work do not work in some Excel files
Summary
- Older version excel file cannot be read in version 3.0.6.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-60a6b3beef1a> in <module>
----> 1 wb = openpyxl.load_workbook("hoge.xlsx")
~/dir/.venv/lib/python3.8/site-packages/openpyxl/reader/excel.py in load_workbook(filename, read_only, keep_vba, data_only, keep_links)
315 reader = ExcelReader(filename, read_only, keep_vba,
316 data_only, keep_links)
--> 317 reader.read()
318 return reader.wb
~/dir/.venv/lib/python3.8/site-packages/openpyxl/reader/excel.py in read(self)
280 self.read_theme()
281 apply_stylesheet(self.archive, self.wb)
--> 282 self.read_worksheets()
283 self.parser.assign_names()
284 if not self.read_only:
~/dir/.venv/lib/python3.8/site-packages/openpyxl/reader/excel.py in read_worksheets(self)
226 ws._rels = rels
227 ws_parser = WorksheetReader(ws, fh, self.shared_strings, self.data_only)
--> 228 ws_parser.bind_all()
229
230 # assign any comments to cells
~/dir/.venv/lib/python3.8/site-packages/openpyxl/worksheet/_reader.py in bind_all(self)
441 def bind_all(self):
442 self.bind_cells()
--> 443 self.bind_merged_cells()
444 self.bind_hyperlinks()
445 self.bind_formatting()
~/dir/.venv/lib/python3.8/site-packages/openpyxl/worksheet/_reader.py in bind_merged_cells(self)
378 for cr in self.parser.merged_cells.mergeCell:
379 mcr = MergedCellRange(self.ws, cr.ref)
--> 380 self.ws._clean_merge_range(mcr)
381 ranges.append(mcr)
382 self.ws.merged_cells = MultiCellRange(ranges)
~/dir/.venv/lib/python3.8/site-packages/openpyxl/worksheet/worksheet.py in _clean_merge_range(self, mcr)
605 for row, col in cells:
606 self._cells[row, col] = MergedCell(self, row, col)
--> 607 mcr.format()
608
609
~/dir/.venv/lib/python3.8/site-packages/openpyxl/worksheet/merge.py in format(self)
107 for name in names:
108 side = getattr(self.start_cell.border, name)
--> 109 if side.style is None:
110 continue # don't need to do anything if there is no border style
111 border = Border(**{name:side})
AttributeError: 'NoneType' object has no attribute 'style'
- This incident does not occur in version 3.0.3
- I haven't yet confirmed which Excel environment the problem occurs in the saved files.
Edited by Yuriko.E