Properties

$sectionId

$sectionId : integer

Section Id

Type

integer

$docPart

$docPart : string

Document part type: Section|Header|Footer|Footnote|Endnote

Used by textrun and cell container to determine where the element is located because it will affect the availability of other element, e.g. footnote will not be available when $docPart is header or footer.

Type

string

$docPartId

$docPartId : integer

Document part Id

For header and footer, this will be = ($sectionId - 1) * 3 + $index because the max number of header/footer in every page is 3, i.e. AUTO, FIRST, and EVEN (AUTO = ODD)

Type

integer

$elementIndex

$elementIndex : integer

Index of element in the elements collection (start with 1)

Type

integer

$elementId

$elementId : string

Unique Id for element

Type

string

$relationId

$relationId : integer

Relation Id

Type

integer

$mediaRelation

$mediaRelation : boolean

Has media relation flag; true for Link, Image, and Object

Type

boolean

$collectionRelation

$collectionRelation : boolean

Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment

Type

boolean

$nestedLevel

$nestedLevel : integer

Depth of table container nested level; Primarily used for RTF writer/reader

0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc.

Type

integer

$parentContainer

$parentContainer : string

Parent container type

Type

string

$minDepth

$minDepth : integer

Min title depth to show

Type

integer

$maxDepth

$maxDepth : integer

Max title depth to show

Type

integer

Methods

setPhpWord()

setPhpWord(\PhpOffice\PhpWord\PhpWord  $phpWord = null) 

Set PhpWord as reference.

Parameters

\PhpOffice\PhpWord\PhpWord $phpWord

getSectionId()

getSectionId() : integer

Get section number

Returns

integer

setDocPart()

setDocPart(string  $docPart, integer  $docPartId = 1) 

Set doc part.

Parameters

string $docPart
integer $docPartId

getDocPart()

getDocPart() : string

Get doc part

Returns

string

getDocPartId()

getDocPartId() : integer

Get doc part Id

Returns

integer

getElementIndex()

getElementIndex() : integer

Get element index

Returns

integer

setElementIndex()

setElementIndex(integer  $value) 

Set element index.

Parameters

integer $value

getElementId()

getElementId() : string

Get element unique ID

Returns

string

setElementId()

setElementId() 

Set element unique ID from 6 first digit of md5.

getRelationId()

getRelationId() : integer

Get relation Id

Returns

integer

setRelationId()

setRelationId(integer  $value) 

Set relation Id.

Parameters

integer $value

getNestedLevel()

getNestedLevel() : integer

Get nested level

Returns

integer

getParent()

getParent() 

setParentContainer()

setParentContainer(\PhpOffice\PhpWord\Element\AbstractElement  $container) 

Set parent container

Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)

Parameters

\PhpOffice\PhpWord\Element\AbstractElement $container

isInSection()

isInSection() : boolean

Check if element is located in Section doc part (as opposed to Header/Footer)

Returns

boolean

setChangeInfo()

setChangeInfo(string  $type, string  $author, null|integer|\DateTime  $date = null) 

Set changed

Parameters

string $type

INSERTED|DELETED

string $author
null|integer|\DateTime $date

allways in UTC

__construct()

__construct(mixed  $fontStyle = null, array  $tocStyle = null, integer  $minDepth = 1, integer  $maxDepth = 9) 

Create a new Table-of-Contents Element

Parameters

mixed $fontStyle
array $tocStyle
integer $minDepth
integer $maxDepth

getTitles()

getTitles() : array

Get all titles

Returns

array

setMaxDepth()

setMaxDepth(integer  $value) 

Set max depth.

Parameters

integer $value

getMaxDepth()

getMaxDepth() : integer

Get Max Depth

Returns

integer —

Max depth of titles

setMinDepth()

setMinDepth(integer  $value) 

Set min depth.

Parameters

integer $value

getMinDepth()

getMinDepth() : integer

Get Min Depth

Returns

integer —

Min depth of titles

setNewStyle()

setNewStyle(mixed  $styleObject, mixed  $styleValue = null, boolean  $returnObject = false) : mixed

Set new style value

Parameters

mixed $styleObject

Style object

mixed $styleValue

Style value

boolean $returnObject

Always return object

Returns

mixed

setEnumVal()

setEnumVal(string|null  $value = null, array<mixed,string>  $enum = array(), string|null  $default = null) : string|null

Set enum value

Parameters

string|null $value
array<mixed,string> $enum
string|null $default

Throws

\InvalidArgumentException

Returns

string|null

getMediaPart()

getMediaPart() : string

Return media element (image, object, link) container name

Returns

string —

section|headerx|footerx|footnote|endnote

setMediaRelation()

setMediaRelation() 

Set relation Id for media elements (link, image, object; legacy of OOXML)

  • Image element needs to be passed to Media object
  • Icon needs to be set for Object element

setCollectionRelation()

setCollectionRelation() 

Set relation Id for elements that will be registered in the Collection subnamespaces.