Commit 630d6bf6 authored by CharlieC's avatar CharlieC
Browse files

Create copies of hyperlinks when working with ranges

Resolves #1502

--HG--
branch : 3.0
parent 3b8c78939a77
# Copyright (c) 2010-2020 openpyxl # Copyright (c) 2010-2020 openpyxl
"""Reader for a single worksheet.""" """Reader for a single worksheet."""
import traceback from copy import copy
from warnings import warn from warnings import warn
# compatibility imports # compatibility imports
...@@ -384,7 +384,7 @@ class WorksheetReader(object): ...@@ -384,7 +384,7 @@ class WorksheetReader(object):
for row in self.ws[link.ref]: for row in self.ws[link.ref]:
for cell in row: for cell in row:
try: try:
cell.hyperlink = link cell.hyperlink = copy(link)
except AttributeError: except AttributeError:
pass pass
else: else:
......
...@@ -49,7 +49,6 @@ class HyperlinkList(Serialisable): ...@@ -49,7 +49,6 @@ class HyperlinkList(Serialisable):
return bool(self.hyperlink) return bool(self.hyperlink)
def __len__(self): def __len__(self):
return len(self.hyperlink) return len(self.hyperlink)
......
...@@ -865,6 +865,7 @@ class TestWorksheetReader: ...@@ -865,6 +865,7 @@ class TestWorksheetReader:
reader.bind_hyperlinks() reader.bind_hyperlinks()
assert ws['B4'].hyperlink.location == "'STP nn000TL-10, PKG 2.52'!A1" assert ws['B4'].hyperlink.location == "'STP nn000TL-10, PKG 2.52'!A1"
assert ws['B4'].hyperlink.ref == "B4"
def test_merged_hyperlinks(self, PrimedWorksheetReader): def test_merged_hyperlinks(self, PrimedWorksheetReader):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment