MCPcopy Index your code
hub / github.com/python-openxml/python-docx / _span_to_width

Method _span_to_width

src/docx/oxml/table.py:691–706  ·  view source on GitHub ↗

Incorporate `w:tc` elements to the right until this cell spans `grid_width`. Incorporated `w:tc` elements are removed (replaced by gridSpan value). Raises |ValueError| if `grid_width` cannot be exactly achieved, such as when a merged cell would drive the span width greater

(self, grid_width: int, top_tc: CT_Tc, vMerge: str | None)

Source from the content-addressed store, hash-verified

689 return top, left, bottom - top, right - left
690
691 def _span_to_width(self, grid_width: int, top_tc: CT_Tc, vMerge: str | None):
692 """Incorporate `w:tc` elements to the right until this cell spans `grid_width`.
693
694 Incorporated `w:tc` elements are removed (replaced by gridSpan value).
695
696 Raises |ValueError| if `grid_width` cannot be exactly achieved, such as when a
697 merged cell would drive the span width greater than `grid_width` or if not
698 enough grid columns are available to make this cell that wide. All content from
699 incorporated cells is appended to `top_tc`. The val attribute of the vMerge
700 element on the single remaining cell is set to `vMerge`. If `vMerge` is |None|,
701 the vMerge element is removed if present.
702 """
703 self._move_content_to(top_tc)
704 while self.grid_span < grid_width:
705 self._swallow_next_tc(grid_width, top_tc)
706 self.vMerge = vMerge
707
708 def _swallow_next_tc(self, grid_width: int, top_tc: CT_Tc):
709 """Extend the horizontal span of this `w:tc` element to incorporate the

Callers 2

_grow_toMethod · 0.95

Calls 2

_move_content_toMethod · 0.95
_swallow_next_tcMethod · 0.95