addList

addList

BASIC / ADVANCED / PREMIUM

Inserts (nested) lists into the Word document.

Description
public addList (array $itemList [, mixed $styleType [, array $options]] )

This method allows the insertion of lists (numbered or with bullets) into your Word document.

You may also include nested lists by means of nested arrays of data and fully customize its contents with the use of WordML fragments.

The following style types are always available:

  • Clear: with no bullet or indentation. This is the default value.
  • Unordered: the standard bulleted list of Word or HTML ul tag.
  • Ordered: the standard ordered list of Word or HTML ol tag.

You may also check all the current available lists styles of your phpdocx base template by means of the parseStyles method. This method returns a Word document including the required phpdocx code to insert the lists that are generated within that document.

You may also use the list styles created via the createListStyle method using the name you gave to your custom list.

Parameters

itemList

The array of data with the (nested) list of items. The possible values of each array entry are:

  • A string of text.
  • An inline WordFragment: all block elements are removed prior to insertion.

styleType

(mixed), 0 (clear), 1 (inordinate) (default), 2 (numerical) or the name of the created list

  • A string of text.
  • An inline WordFragment: all block elements are removed prior to insertion.

options

The possible keys and values are (required options are shown with yellow background):

key Type Description
bold bool If true the text will be shown in bold characters.
caps bool If true displays text in capital letters.
color string Hexadecimal color value: 'FF0000', '000000', ...
font string Font family: 'Arial', Calibri', ...
fontSize int Font size in points.
highlightColor string Highlights the run of text. The available colors are: black, blue, cyan, green, magenta, red, yellow, white, darkBlue, darkCyan, darkGreen, darkMagenta, darkRed, darkYellow, darkGray, lightGray, none.
italic string If true displays the text in italics.
pStyle string Word style to be used. Run parseStyles() method to check all available paragraph styles.
rtl bool Sets to true for right to left languages like Hebrew or Arabic.
smallCaps bool If true displays text in small capital letters.
underline string Underlines text. Possible values are: single, words, double, dotted, dash and wave.
useWordFragmentStyles bool Use WordFragment paragraph styles.
Return values

Void.

Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like:

Example #3

The resulting Word document looks like:

Example #4

The resulting Word document looks like: