We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5a1d614 commit 6d49a69Copy full SHA for 6d49a69
src/docx/oxml/table.py
@@ -748,11 +748,10 @@ def _tr_above(self) -> CT_Row:
748
749
Raises |ValueError| if called on a cell in the top-most row.
750
"""
751
- tr_lst = self._tbl.tr_lst
752
- tr_idx = tr_lst.index(self._tr)
753
- if tr_idx == 0:
754
- raise ValueError("no tr above topmost tr")
755
- return tr_lst[tr_idx - 1]
+ tr_aboves = self.xpath("./ancestor::w:tr[position()=1]/preceding-sibling::w:tr[1]")
+ if not tr_aboves:
+ raise ValueError("no tr above topmost tr in w:tbl")
+ return tr_aboves[0]
756
757
@property
758
def _tr_below(self) -> CT_Row | None:
0 commit comments