MCPcopy
hub / github.com/python-openxml/python-docx / clear_content

Method clear_content

src/docx/oxml/table.py:449–458  ·  view source on GitHub ↗

Remove all content elements, preserving `w:tcPr` element if present. Note that this leaves the `w:tc` element in an invalid state because it doesn't contain at least one block-level element. It's up to the caller to add a `w:p`child element as the last content element.

(self)

Source from the content-addressed store, hash-verified

447 return self._tr_idx + 1
448
449 def clear_content(self):
450 """Remove all content elements, preserving `w:tcPr` element if present.
451
452 Note that this leaves the `w:tc` element in an invalid state because it doesn't
453 contain at least one block-level element. It's up to the caller to add a
454 `w:p`child element as the last content element.
455 """
456 # -- remove all cell inner-content except a `w:tcPr` when present. --
457 for e in self.xpath("./*[not(self::w:tcPr)]"):
458 self.remove(e)
459
460 @property
461 def grid_offset(self) -> int:

Callers 2

clearMethod · 0.45
clearMethod · 0.45

Calls 1

xpathMethod · 0.80

Tested by

no test coverage detected