addTable

addTable

BASIC / ADVANCED / PREMIUM

Adds tables into the PowerPoint presentation.

Description
public addTable($contents, $position, $tableStyles = array(), $rowStyles = array(), $options = array())

This method inserts tables into the PowerPoint presentation.

Parameters

contents

A multidimensional array of cell contents and styles. PptxFragments can be used to add contents.

Key Type Description
text string|array See addText for text styles.
align string left, center, right, justify
backgroundColor string HEX color
border array

'top', 'right', 'bottom', 'left' keys can be used to set borders

  • 'dash' (string) solid, dot, dash, lgDash, dashDot, lgDashDot, lgDashDotDot, sysDash, sysDot, sysDashDot, sysDashDotDot.
  • 'color' (string) default as 000000. none to avoid adding the color.
  • 'width' (int) EMUs (English Metric Unit). Default as 12700 (1pt).
cellMargin array
  • 'top' (int)
  • 'right' (int)
  • 'bottom' (int)
  • 'left' (int)
colspan int HEX color.
rowspan int
textDirection string horz, vert, vert270, wordArtVert, eaVert, mongolianVert, wordArtVertRtl.
verticalAlign string top, middle, bottom, topCentered, middleCentered, bottomCentered.
wrap string square, none.

position

Key Type Description
new array

A new position is generated.

  • 'coordinateX' (int) EMUs (English Metric Unit).
  • 'coordinateY' (int) EMUs (English Metric Unit).
  • 'sizeX' (int) EMUs (English Metric Unit).
  • 'sizeY' (int) EMUs (English Metric Unit).
  • 'name' (string) placeholder internal name. If not set, a random name is generated.
  • 'order' (int) set the display order. Default after existing contents. 0 is the first order position. If the order position doesn't exist add after existing contents.

tableStyles

Key Type Description
backgroundColor string HEX color.
bandedColumns bool Banded columns. Default as false.
bandedRows bool Banded rows. Default as false.
border array
  • 'dash' (string) solid, dot, dash, lgDash, dashDot, lgDashDot, lgDashDotDot, sysDash, sysDot, sysDashDot, sysDashDotDot.
  • 'color' (string) default as 000000. none to avoid adding the color.
  • 'width' (int) EMUs (English Metric Unit). Default as 12700 (1pt).
cellMargin array
  • 'top' (int)
  • 'right' (int)
  • 'bottom' (int)
  • 'left' (int)
columnWidths int|array Column width fix (int) or column width variable (array). If not set, get from the shape size. EMUs (English Metric Unit).
firstColumn bool First column. Default as false.
headerRow bool Header row. Default as false.
lastColumn bool Last column. Default as false.
style string Table style name. Using a template, if the table doesn't exist, try to import it from the base template.
totalRow bool Total row. Default as false.

rowStyles

Array for each row.

Key Type Description
height int EMUs (English Metric Unit).
Exceptions

Position not valid.

Table style doesn't exist.

Code samples

Example #1

The resulting PPTX looks like:

Example #2

The resulting PPTX looks like:

Example #3

The resulting PPTX looks like:

Example #4

The resulting PPTX looks like:

Release notes
  • phppptx 1.0:
    • new method.