MCPcopy Create free account
hub / github.com/scanny/python-pptx / Table

Class Table

src/pptx/table.py:22–165  ·  view source on GitHub ↗

A DrawingML table object. Not intended to be constructed directly, use :meth:`.Slide.shapes.add_table` to add a table to a slide.

Source from the content-addressed store, hash-verified

20
21
22class Table(object):
23 """A DrawingML table object.
24
25 Not intended to be constructed directly, use
26 :meth:`.Slide.shapes.add_table` to add a table to a slide.
27 """
28
29 def __init__(self, tbl: CT_Table, graphic_frame: GraphicFrame):
30 super(Table, self).__init__()
31 self._tbl = tbl
32 self._graphic_frame = graphic_frame
33
34 def cell(self, row_idx: int, col_idx: int) -> _Cell:
35 """Return cell at `row_idx`, `col_idx`.
36
37 Return value is an instance of |_Cell|. `row_idx` and `col_idx` are zero-based, e.g.
38 cell(0, 0) is the top, left cell in the table.
39 """
40 return _Cell(self._tbl.tc(row_idx, col_idx), self)
41
42 @lazyproperty
43 def columns(self) -> _ColumnCollection:
44 """|_ColumnCollection| instance for this table.
45
46 Provides access to |_Column| objects representing the table's columns. |_Column| objects
47 are accessed using list notation, e.g. `col = tbl.columns[0]`.
48 """
49 return _ColumnCollection(self._tbl, self)
50
51 @property
52 def first_col(self) -> bool:
53 """When `True`, indicates first column should have distinct formatting.
54
55 Read/write. Distinct formatting is used, for example, when the first column contains row
56 headings (is a side-heading column).
57 """
58 return self._tbl.firstCol
59
60 @first_col.setter
61 def first_col(self, value: bool):
62 self._tbl.firstCol = value
63
64 @property
65 def first_row(self) -> bool:
66 """When `True`, indicates first row should have distinct formatting.
67
68 Read/write. Distinct formatting is used, for example, when the first row contains column
69 headings.
70 """
71 return self._tbl.firstRow
72
73 @first_row.setter
74 def first_row(self, value: bool):
75 self._tbl.firstRow = value
76
77 @property
78 def horz_banding(self) -> bool:
79 """When `True`, indicates rows should have alternating shading.

Callers 9

tableMethod · 0.90
dx_fixtureMethod · 0.90
dy_fixtureMethod · 0.90
boolprop_get_fixtureMethod · 0.90
boolprop_set_fixtureMethod · 0.90

Calls

no outgoing calls

Tested by 8

dx_fixtureMethod · 0.72
dy_fixtureMethod · 0.72
boolprop_get_fixtureMethod · 0.72
boolprop_set_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…