XML API - pdx:addTable
- addBackgroundImage
- addFooter
- addHeader
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createCharacterStyle
- createListStyle
- createParagraphStyle
- docxSettings
- importHeadersAndFooters
- importListStyle
- importStyles
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- addBookmark
- addBreak
- addChart
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addStructuredDocumentTag
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordML
- embedHTML
- clearBlocks
- deleteBlock
- modifyInputFields
- processTemplate
- rawSearchAndReplace
- removeTemplateVariable
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
pdx:addTable
Inserts a table into a Word document.
Note
You are reading the XML API documentation. For the PHP API method please go to addTable.
Element definition
This element allows the insertion of a table into your Word document.
You may:
- Create tables with complex row and col spans.
- Insert in each single table cell:
- plain text
- rich text
- nested tables
- lists
- images
- charts
- footnotes and endnotes
- any combination of all the above
- Style the table as a whole and/or its individual rows and cells: set, for example, global properties like borders and margins that can be overridden for each table cell.
- You may position the table by its own or make it float so the surrounding text will wrap around it.
Like in the standard MS Word interface, tables, by default, have a black border in every cell. If you want a borderless table you should specify the border option to none in tableProperties
tableData
These entries may be:
- a simple string of text
- a WordFragment element
The first option is only valid for very simple tables that only contain plain text.
The WordFragments are only needed if you want to insert images, charts, nested tables or complex paragraphs.
Key | Description |
---|---|
value | The text to be inserted (string) or a Word fragment if you want to insert complex paragraphs, images, nested tables... |
backgroundColor | Hexadecimal color value: 'FF0000', '000000'... |
border | Border type: none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset... This value can be overridden for each side with the use 'borderTop', 'borderRight', 'borderBottom' and 'borderLeft' properties. |
borderColor | Hexadecimal color value: 'FF0000', '000000'... This value can be overridden for each side with the use of 'borderTopColor', 'borderRightColor', 'borderBottomColor' and 'borderLeftColor' properties. |
borderSpacing | Border spacing in points. This value can be overridden for each side with the use of 'borderTopSpacing', 'borderRightSpacing', 'borderBottomSpacing' and 'borderLeftSpacing' properties. |
borderWidth | Border size in eigths of a point. This value can be overridden for each side with the use of 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth' and 'borderLeftWidth' properties. |
cellMargin | An integer or an array with keys: top, right, bottom and left. The values are given in twentieths of a point. |
colspan | The col span of that particular table cell. |
fitText | If true fits the text to the size of the cell. |
noWrap | If true text does not wrap. |
rowspan | The row span of that particular table cell. |
textDirection | Sets the direction of the flow of text. Available values are: lr (default), tbRl and btLr. |
vAlign | Vertical align of text: top, center, both or bottom. |
width | Preferred cell width in twentieths of a point (twips). |
tableProperties
This is an array including all general table options (some of them may be overridden by row or cell properties).
The possible keys and values of this array are:
Key | Description |
---|---|
bidi | Sets to 'true' for right to left languages (default value is 'false'). |
border | Border type: none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset... By default the border type is single. You should select none for borderless tables. |
borderColor | Hexadecimal color value: 'FF0000', '000000'... |
borderSpacing | Border spacing in points. |
borderWidth | Border size in eigths of a point. |
borderSettings | Possible values are: all, outside, inside. If all (default value) the border styles apply to all table borders. If the value is set to outside or inside the border styles will only apply to the outside or inside borders respectively. |
cantSplitRows | Sets global row split properties (can be overriden or set for individual rows by rowProperties). |
cellMargin | General cell margins for the whole table. An integer or an array with keys: top, right, bottom and left. The values are given in twentieths of a point. |
cellSpacing | Separation among cells. Given in twentieths of a point (twips). |
columnWidths | An integer or a zero-based array with the widths of each column in twentieths of a point. |
conditionalFormatting | This option lets you control which formatting conditions declared in the corresponding table style should be applied. The possible keys and values are:
|
float | With the following keys and values:
|
font | Font family: 'Arial', Calibri'... |
indent | Left table margin in twentieths of a point (twips). |
tableAlign | Table alignment. Possible values are: center, left or right. |
tableLayout | Possible values are: fixed or autofit (default). Set it to 'fixed' only if you do not want Word to handle the best possible width. |
tableStyle | Word table style id (you may run parseStyles element to check for the available styles in phpdocx or your particular template). |
tableWidth | Its possible keys and values are:
|
textProperties | It may include any of the paragraph properties of the addText element so you can completely customize the properies of the text content of the table. |
rowProperties
This is an array of arrays (one for each row you want to customize) including all available row options.
The possible keys and values of each of these arrays are:
Key | Description |
---|---|
cantSplit | If true the row cannot split across pages. |
height | Exact row height in twentieths of a point (twips). |
minHeight | Minimum row height in twentieths of a point (twips). |
tableHeader | If true, and the table splits across pages, this row repeats at the beginning of each new page. |