createTableStyle

createTableStyle

TRIAL / ADVANCED / PREMIUM

Creates a new Word table style.

Description
public createTableStyle ( string $name [, array $styleOptions = array() ])

This method allows the generation of custom table styles that may be later used in combination with, for example, the addTable method.

Parameters

name

A string with the name of the Word style that you are creating.

styleOptions

This is an array including all the available styling options.

Key Type Description
border string 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 string Hexadecimal color value: 'FF0000', '000000'... This value can be overridden for each side with the use of 'borderTopColor', 'borderRightColor', 'borderBottomColor' and 'borderLeftColor' properties.
borderSpacing int Border spacing in points. This value can be overridden for each side with the use of 'borderTopSpacing', 'borderRightSpacing', 'borderBottomSpacing' and 'borderLeftSpacing' properties.
borderWidth int 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.
cellBackgroundColor string Hexadecimal color value: 'FF0000', '000000'...
cellMargin mixed An integer or an array with keys: top, right, bottom and left. The values are given in twentieths of a point.
indent int Table indentation. The value is given in twentieths of a point.
rPrStyles array Character styles to be applied.
pPrStyles array Paragraph styles to be applied.
tableStyle string Id of the style this table style is based on (it may be retrieved with the parseStyles method).
tblStyleColBandSize bool Column banded style.
tblStyleRowBandSize bool Row banded style.
band1HorzStyle array Set odd rows styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
band1VertStyle array Sets odd cols styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
band2HorzStyle array Sets even rows styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
band2VertStyle array Sets even cols styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
firstColStyle array Sets first column styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
firstRowStyle array Sets first row styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
hidden bool Hide style from user interface.
lastColStyle array Sets last col styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
lastRowStyle array Sets last row styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
locked bool Style cannot be applied.
next string Style for next paragraph.
neCellStyle array Sets top right styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
nwCellStyle array Sets top left styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
seCellStyle array Sets bottom right styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
semiHidden bool Hide style from main user interface.
swCellStyle array Sets bottom left styles using border, borderColor, borderSpacing, borderWidth, backgroundColor, vAlign, rPrStyles, pPrStyles properties.
unhideWhenUsed bool Remove semi-hidden property when style is used.
Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like:

Release notes
  • phpdocx 13.0:
    • cellBackgroundColor option.
  • phpdocx 12.0:
    • hidden, semiHidden, unhideWhenUsed, locked and next options.
  • phpdocx 8.5:
    • new method.