表格属性
================
Table Properties
对齐
---------
Alignment
.. tab:: 中文
Word 允许表格在页边距之间左对齐、右对齐或居中对齐。
读/写 :attr:`Table.alignment` 属性指定表格的对齐方式
.. tab:: 英文
Word allows a table to be aligned between the page margins either left, right, or center.
The read/write :attr:`Table.alignment` property specifies the alignment for a table
::
>>> table = document.add_table(rows=2, cols=2)
>>> table.alignment
None
>>> table.alignment = WD_TABLE_ALIGNMENT.RIGHT
>>> table.alignment
RIGHT (2)
自动调整
-------
Autofit
.. tab:: 中文
Word 有两种表格布局算法, *固定宽度* 或 `自动调整(autofit)`。默认使用自动调整。在自动调整表格中,Word 会根据单元格内容调整列宽。固定宽度表格则会保持列宽不变,无论内容如何。无论使用哪种算法,当表格总宽度超过页面宽度时,都会按比例调整列宽。
读写属性 :attr:`Table.allow_autofit` 指定使用哪种算法。
.. tab:: 英文
Word has two algorithms for laying out a table, *fixed-width* or `autofit`. The default is autofit. Word will adjust column widths in an autofit table based on cell contents. A fixed-width table retains its column widths regardless of the contents. Either algorithm will adjust column widths proportionately when total table width exceeds page width.
The read/write :attr:`Table.allow_autofit` property specifies which algorithm is used
::
>>> table = document.add_table(rows=2, cols=2)
>>> table.allow_autofit
True
>>> table.allow_autofit = False
>>> table.allow_autofit
False
样本 XML
------------
Specimen XML
.. highlight:: xml
.. tab:: 中文
以下 XML 表示 2x2 表
.. tab:: 英文
The following XML represents a 2x2 table
::
布局行为
---------------
Layout behavior
.. tab:: 中文
自动布局会导致实际列宽不可预测且不稳定。内容的更改可能会导致表格布局发生变化。
.. tab:: 英文
Auto-layout causes actual column widths to be both unpredictable and unstable. Changes to the content can make the table layout shift.
CT_TblWidth 元素的语义
--------------------------------
Semantics of CT_TblWidth element
e.g. ``tcW``::
ST_MeasurementOrPercent
|
+-- ST_DecimalNumberOrPercent
| |
| +-- ST_UnqualifiedPercentage
| | |
| | +-- XsdInteger e.g. '1440'
| |
| +-- ST_Percentage e.g. '-07.43%'
|
+-- ST_UniversalMeasure e.g. '-04.34mm'
架构定义
------------------
Schema Definitions
.. tab:: 中文
.. tab:: 英文
.. highlight:: xml
::