Commit f6a04828 authored by eirikur@Eirikurs-MacBook-Pro.local's avatar eirikur@Eirikurs-MacBook-Pro.local
Browse files

Change how the top-left cell of a merged range is found

branch : fix-mergedcell-hyperlink-read-only
parent c2df7930dec7
......@@ -378,14 +378,18 @@ class WorksheetReader(object):
cell =[link.ref]
cell = self._change_to_top_left_cell_if_merged(cell)
if isinstance(cell, MergedCell):
cell = self.normalize_merged_cell_link(cell.coordinate)
cell.hyperlink = link
def _change_to_top_left_cell_if_merged(self, cell):
if not isinstance(cell, MergedCell):
return cell
r =
def normalize_merged_cell_link(self, coord):
Returns the appropriate cell to which a hyperlink, which references a merged cell at the specified coordinates,
should be bound.
for rng in
if coord in rng:
def bind_col_dimensions(self):
for col, cd in self.parser.column_dimensions.items():
......@@ -91,12 +91,6 @@ class CellRange(Serialisable):
def top_left_coord(self):
Coordinate of the cell in the top left corner of the range
return get_column_letter(self.min_col) + str(self.min_row)
def rows(self):
......@@ -505,13 +499,3 @@ class MultiCellRange(Strict):
for r in self.ranges:
return n
def find_range_containing(self, coord):
Finds and returns the first range that contains the cell with the specified coordinates.
Returns None if no range is found.
for r in self.ranges:
if coord in r:
return r
return None
......@@ -800,6 +800,21 @@ class TestWorksheetReader:
assert ws.merged_cells == "G18:H18 G23:H24 A18:B18"
argvalues=[("H18", "G18"), ("G18", "G18"), ("I18", None), ("H23", "G23")])
def test_normalize_merged_cell_link(self, PrimedWorksheetReader, input_coordinate, expected_coordinate):
reader = PrimedWorksheetReader
normalized = reader.normalize_merged_cell_link(input_coordinate)
if expected_coordinate is None:
assert normalized is None
assert normalized.coordinate == expected_coordinate
def test_external_hyperlinks(self, PrimedWorksheetReader):
reader = 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