`` `` element.
| 144 | |
| 145 | |
| 146 | class CT_Tbl(BaseOxmlElement): |
| 147 | """``<w:tbl>`` element.""" |
| 148 | |
| 149 | add_tr: Callable[[], CT_Row] |
| 150 | tr_lst: list[CT_Row] |
| 151 | |
| 152 | tblPr: CT_TblPr = OneAndOnlyOne("w:tblPr") # pyright: ignore[reportAssignmentType] |
| 153 | tblGrid: CT_TblGrid = OneAndOnlyOne("w:tblGrid") # pyright: ignore[reportAssignmentType] |
| 154 | tr = ZeroOrMore("w:tr") |
| 155 | |
| 156 | @property |
| 157 | def bidiVisual_val(self) -> bool | None: |
| 158 | """Value of `./w:tblPr/w:bidiVisual/@w:val` or |None| if not present. |
| 159 | |
| 160 | Controls whether table cells are displayed right-to-left or left-to-right. |
| 161 | """ |
| 162 | bidiVisual = self.tblPr.bidiVisual |
| 163 | if bidiVisual is None: |
| 164 | return None |
| 165 | return bidiVisual.val |
| 166 | |
| 167 | @bidiVisual_val.setter |
| 168 | def bidiVisual_val(self, value: WD_TABLE_DIRECTION | None): |
| 169 | tblPr = self.tblPr |
| 170 | if value is None: |
| 171 | tblPr._remove_bidiVisual() # pyright: ignore[reportPrivateUsage] |
| 172 | else: |
| 173 | tblPr.get_or_add_bidiVisual().val = bool(value) |
| 174 | |
| 175 | @property |
| 176 | def col_count(self): |
| 177 | """The number of grid columns in this table.""" |
| 178 | return len(self.tblGrid.gridCol_lst) |
| 179 | |
| 180 | def iter_tcs(self): |
| 181 | """Generate each of the `w:tc` elements in this table, left to right and top to |
| 182 | bottom. |
| 183 | |
| 184 | Each cell in the first row is generated, followed by each cell in the second |
| 185 | row, etc. |
| 186 | """ |
| 187 | for tr in self.tr_lst: |
| 188 | for tc in tr.tc_lst: |
| 189 | yield tc |
| 190 | |
| 191 | @classmethod |
| 192 | def new_tbl(cls, rows: int, cols: int, width: Length) -> CT_Tbl: |
| 193 | """Return a new `w:tbl` element having `rows` rows and `cols` columns. |
| 194 | |
| 195 | `width` is distributed evenly between the columns. |
| 196 | """ |
| 197 | return cast(CT_Tbl, parse_xml(cls._tbl_xml(rows, cols, width))) |
| 198 | |
| 199 | @property |
| 200 | def tblStyle_val(self) -> str | None: |
| 201 | """`w:tblPr/w:tblStyle/@w:val` (a table style id) or |None| if not present.""" |
| 202 | tblStyle = self.tblPr.tblStyle |
| 203 | if tblStyle is None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…