Python docx table grid

Table objects¶

Table objects are constructed using the add_table() method on Document .

Table objects¶

Proxy class for a WordprocessingML element.

Return a _Column object of width, newly added rightmost to the table.

Return a _Row instance, newly added bottom-most to the table.

Read/write. A member of WD_TABLE_ALIGNMENT or None, specifying the positioning of this table between the page margins. None if no setting is specified, causing the effective value to be inherited from the style hierarchy.

True if column widths can be automatically adjusted to improve the fit of cell contents. False if table layout is fixed. Column widths are adjusted in either case if total column width exceeds page width. Read/write boolean.

Return _Cell instance correponding to table cell at row_idx, col_idx intersection, where (0, 0) is the top, left-most cell.

Sequence of cells in the column at column_idx in this table.

_Columns instance representing the sequence of columns in this table.

Sequence of cells in the row at row_idx in this table.

_Rows instance containing the sequence of rows in this table.

Read/write. A _TableStyle object representing the style applied to this table. The default table style for the document (often Normal Table ) is returned if the table has no directly-applied style. Assigning None to this property removes any directly-applied table style causing it to inherit the default table style of the document. Note that the style name of a table style differs slightly from that displayed in the user interface; a hyphen, if it appears, must be removed. For example, Light Shading — Accent 1 becomes Light Shading Accent 1 .

A member of WD_TABLE_DIRECTION indicating the direction in which the table cells are ordered, e.g. WD_TABLE_DIRECTION.LTR . None indicates the value is inherited from the style hierarchy.

_Cell objects¶

Return a paragraph newly added to the end of the content in this cell. If present, text is added to the paragraph in a single run. If specified, the paragraph style style is applied. If style is not specified or is None , the result is as though the ‘Normal’ style was applied. Note that the formatting of text in a cell can be influenced by the table style. text can contain tab ( \t ) characters, which are converted to the appropriate XML form for a tab. text can also include newline ( \n ) or carriage return ( \r ) characters, each of which is converted to a line break.

Читайте также:  Send email by gmail in java

Return a table newly added to this cell after any existing cell content, having rows rows and cols columns. An empty paragraph is added after the table because Word requires a paragraph element as the last element in every cell.

Return a merged cell created by spanning the rectangular region having this cell and other_cell as diagonal corners. Raises InvalidSpanError if the cells do not define a rectangular region.

List of paragraphs in the cell. A table cell is required to contain at least one block-level element and end with a paragraph. By default, a new cell contains a single paragraph. Read-only

List of tables in the cell, in the order they appear. Read-only.

The entire contents of this cell as a string of text. Assigning a string to this property replaces all existing content with a single paragraph containing the assigned text in a single run.

A value of None indicates vertical alignment for this cell is inherited. Assigning None causes any explicitly defined vertical alignment to be removed, restoring inheritance.

The width of this cell in EMU, or None if no explicit width is set.

_Row objects¶

Sequence of _Cell instances corresponding to cells in this row.

Return a Length object representing the height of this cell, or None if no explicit height is set.

Return the height rule of this cell as a member of the WD_ROW_HEIGHT_RULE enumeration, or None if no explicit height_rule is set.

Reference to the Table object this row belongs to.

_Column objects¶

Sequence of _Cell instances corresponding to cells in this column.

Reference to the Table object this column belongs to.

The width of this column in EMU, or None if no explicit width is set.

_Rows objects¶

Sequence of _Row objects corresponding to the rows in a table. Supports len() , iteration, indexed access, and slicing.

Читайте также:  Javascript split for var

Reference to the Table object this row collection belongs to.

_Columns objects¶

Sequence of _Column instances corresponding to the columns in a table. Supports len() , iteration and indexed access.

Reference to the Table object this column collection belongs to.

Table of Contents

Источник

Table¶

A table is composed of rows of cells. An implicit sequence of grid columns align cells across rows. If there are no merged cells, the grid columns correspond directly to the visual columns.

All table content is contained in its cells.

In addition to this overview, there are the following more specialized feature analyses:

Specimen XML¶

The following XML is generated by Word when inserting a 2×2 table:

   w:val="TableGrid"/>  w:type="auto" w:w="0"/>  w:firstColumn="1" w:firstRow="1" w:lastColumn="0" w:lastRow="0" w:noHBand="0" w:noVBand="1" w:val="04A0"/>   w:w="4788"/>  w:w="4788"/>    w:type="dxa" w:w="4788"/>      w:type="dxa" w:w="4788"/>        w:type="dxa" w:w="4788"/>      w:type="dxa" w:w="4788"/>      

Schema Definitions¶

 name="CT_Tbl">   ref="EG_RangeMarkupElements" minOccurs="0" maxOccurs="unbounded"/>  name="tblPr" type="CT_TblPr"/>  name="tblGrid" type="CT_TblGrid"/>  minOccurs="0" maxOccurs="unbounded">  name="tr" type="CT_Row"/>  name="customXml" type="CT_CustomXmlRow"/>  name="sdt" type="CT_SdtRow"/>  ref="EG_RunLevelElts" minOccurs="0" maxOccurs="unbounded"/>     name="CT_TblPr">   name="tblStyle" type="CT_String" minOccurs="0"/>  name="tblpPr" type="CT_TblPPr" minOccurs="0"/>  name="tblOverlap" type="CT_TblOverlap" minOccurs="0"/>  name="bidiVisual" type="CT_OnOff" minOccurs="0"/>  name="tblStyleRowBandSize" type="CT_DecimalNumber" minOccurs="0"/>  name="tblStyleColBandSize" type="CT_DecimalNumber" minOccurs="0"/>  name="tblW" type="CT_TblWidth" minOccurs="0"/>  name="jc" type="CT_JcTable" minOccurs="0"/>  name="tblCellSpacing" type="CT_TblWidth" minOccurs="0"/>  name="tblInd" type="CT_TblWidth" minOccurs="0"/>  name="tblBorders" type="CT_TblBorders" minOccurs="0"/>  name="shd" type="CT_Shd" minOccurs="0"/>  name="tblLayout" type="CT_TblLayoutType" minOccurs="0"/>  name="tblCellMar" type="CT_TblCellMar" minOccurs="0"/>  name="tblLook" type="CT_TblLook" minOccurs="0"/>  name="tblCaption" type="CT_String" minOccurs="0"/>  name="tblDescription" type="CT_String" minOccurs="0"/>  name="tblPrChange" type="CT_TblPrChange" minOccurs="0"/>   name="CT_TblGrid">   name="gridCol" type="CT_TblGridCol" minOccurs="0" maxOccurs="unbounded"/>  name="tblGridChange" type="CT_TblGridChange" minOccurs="0"/>    name="CT_TblGridCol">  name="w" type="s:ST_TwipsMeasure"/>   name="CT_Row">  name="tblPrEx" type="CT_TblPrEx" minOccurs="0"/>  name="trPr" type="CT_TrPr" minOccurs="0"/>  ref="EG_ContentCellContent" minOccurs="0" maxOccurs="unbounded"/>   name="rsidRPr" type="ST_LongHexNumber"/>  name="rsidR" type="ST_LongHexNumber"/>  name="rsidDel" type="ST_LongHexNumber"/>  name="rsidTr" type="ST_LongHexNumber"/>   name="EG_ContentCellContent">  name="tc" type="CT_Tc" minOccurs="0" maxOccurs="unbounded"/>  name="customXml" type="CT_CustomXmlCell"/>  name="sdt" type="CT_SdtCell"/>  ref="EG_RunLevelElts" minOccurs="0" maxOccurs="unbounded"/>    name="EG_RunLevelElts">   name="proofErr" type="CT_ProofErr"/>  name="permStart" type="CT_PermStart"/>  name="permEnd" type="CT_Perm"/>  name="ins" type="CT_RunTrackChange"/>  name="del" type="CT_RunTrackChange"/>  name="moveFrom" type="CT_RunTrackChange"/>  name="moveTo" type="CT_RunTrackChange"/>  ref="m:oMathPara" type="CT_OMathPara"/>  ref="m:oMath" type="CT_OMath"/>  name="bookmarkStart" type="CT_Bookmark"/>  name="bookmarkEnd" type="CT_MarkupRange"/>  name="moveFromRangeStart" type="CT_MoveBookmark"/>  name="moveFromRangeEnd" type="CT_MarkupRange"/>  name="moveToRangeStart" type="CT_MoveBookmark"/>  name="moveToRangeEnd" type="CT_MarkupRange"/>  name="commentRangeStart" type="CT_MarkupRange"/>  name="commentRangeEnd" type="CT_MarkupRange"/>  name="customXmlInsRangeStart" type="CT_TrackChange"/>  name="customXmlInsRangeEnd" type="CT_Markup"/>  name="customXmlDelRangeStart" type="CT_TrackChange"/>  name="customXmlDelRangeEnd" type="CT_Markup"/>  name="customXmlMoveFromRangeStart" type="CT_TrackChange"/>  name="customXmlMoveFromRangeEnd" type="CT_Markup"/>  name="customXmlMoveToRangeStart" type="CT_TrackChange"/>  name="customXmlMoveToRangeEnd" type="CT_Markup"/>    name="EG_RangeMarkupElements">  name="bookmarkStart" type="CT_Bookmark"/>  name="bookmarkEnd" type="CT_MarkupRange"/>  name="moveFromRangeStart" type="CT_MoveBookmark"/>  name="moveFromRangeEnd" type="CT_MarkupRange"/>  name="moveToRangeStart" type="CT_MoveBookmark"/>  name="moveToRangeEnd" type="CT_MarkupRange"/>  name="commentRangeStart" type="CT_MarkupRange"/>  name="commentRangeEnd" type="CT_MarkupRange"/>  name="customXmlInsRangeStart" type="CT_TrackChange"/>  name="customXmlInsRangeEnd" type="CT_Markup"/>  name="customXmlDelRangeStart" type="CT_TrackChange"/>  name="customXmlDelRangeEnd" type="CT_Markup"/>  name="customXmlMoveFromRangeStart" type="CT_TrackChange"/>  name="customXmlMoveFromRangeEnd" type="CT_Markup"/>  name="customXmlMoveToRangeStart" type="CT_TrackChange"/>  name="customXmlMoveToRangeEnd" type="CT_Markup"/>    name="ST_TwipsMeasure">  memberTypes="ST_UnsignedDecimalNumber ST_PositiveUniversalMeasure"/>   name="ST_UnsignedDecimalNumber">  base="xsd:unsignedLong"/>   name="ST_PositiveUniversalMeasure">  base="ST_UniversalMeasure">  value="9+(\.9+)?(mm|cm|in|pt|pc|pi)"/>   

Источник

Оцените статью