Cell
extends AbstractContainer
in package
Table cell element.
Table of Contents
Properties
- $collectionRelation : bool
- Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.
- $commentsRangeEnd : Comments
- The end position for the linked comments.
- $commentsRangeStart : Comments
- The start position for the linked comments.
- $container : string
- Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange.
- $docPart : string
- Document part type: Section|Header|Footer|Footnote|Endnote.
- $docPartId : int
- Document part Id.
- $elementId : string
- Unique Id for element.
- $elementIndex : int
- Index of element in the elements collection (start with 1).
- $elements : array<string|int, AbstractElement>
- Elements collection.
- $mediaRelation : bool
- Has media relation flag; true for Link, Image, and Object.
- $phpWord : PhpWord|null
- PhpWord object.
- $relationId : int
- Relation Id.
- $sectionId : int
- Section Id.
- $nestedLevel : int
- Depth of table container nested level; Primarily used for RTF writer/reader.
- $parent : null|AbstractElement
- A reference to the parent.
- $parentContainer : string
- Parent container type.
- $style : Cell|null
- Cell style.
- $trackChange : TrackChange
- changed element info.
- $width : int|null
- Cell width.
Methods
- __call() : AbstractElement
- Magic method to catch all 'addElement' variation.
- __construct() : mixed
- Create new instance.
- addBookmark() : Bookmark
- addChart() : Chart
- addCheckBox() : CheckBox
- addEndnote() : Endnote
- addField() : Field
- addFootnote() : Footnote
- addFormField() : FormField
- addFormula() : Formula
- addImage() : Image
- addLine() : Line
- addLink() : Link
- addListItem() : ListItem
- addListItemRun() : ListItemRun
- addObject() : OLEObject
- addOLEObject() : OLEObject
- addPageBreak() : PageBreak
- addPreserveText() : PreserveText
- addSDT() : SDT
- addShape() : Shape
- addTable() : Table
- addText() : Text
- addTextBox() : TextBox
- addTextBreak() : void
- addTextRun() : TextRun
- addTitle() : Title
- addTOC() : TOC
- countElements() : int
- Count elements.
- getCommentRangeEnd() : Comment
- Get comment end.
- getCommentRangeStart() : Comment
- Get comment start.
- getCommentsRangeEnd() : Comments
- Get comments end.
- getCommentsRangeStart() : Comments
- Get comments start.
- getDocPart() : string
- Get doc part.
- getDocPartId() : int
- Get doc part Id.
- getElement() : null|AbstractElement
- Returns the element at the requested position.
- getElementId() : string
- Get element unique ID.
- getElementIndex() : int
- Get element index.
- getElements() : array<string|int, AbstractElement>
- Get all elements.
- getNestedLevel() : int
- Get nested level.
- getParent() : null|AbstractElement
- Get parent element.
- getPhpWord() : PhpWord|null
- Get PhpWord.
- getRelationId() : int
- Get relation Id.
- getSectionId() : int
- Get section number.
- getStyle() : Cell|null
- Get cell style.
- getTrackChange() : TrackChange
- Gets the trackChange information.
- getWidth() : int|null
- Get cell width.
- isInSection() : bool
- Check if element is located in Section doc part (as opposed to Header/Footer).
- removeElement() : void
- Removes the element at requested index.
- setChangeInfo() : void
- Set changed.
- setCommentRangeEnd() : void
- Set comment end.
- setCommentRangeStart() : void
- Set comment start.
- setDocPart() : void
- Set doc part.
- setElementId() : void
- Set element unique ID from 6 first digit of md5.
- setElementIndex() : void
- Set element index.
- setParentContainer() : void
- Set parent container.
- setPhpWord() : void
- Set PhpWord as reference.
- setRelationId() : void
- Set relation Id.
- setTrackChange() : void
- Sets the trackChange information.
- addElement() : AbstractElement
- Add element.
- setEnumVal() : null|string
- Set enum value.
- setNewStyle() : mixed
- Set new style value.
- checkValidity() : bool
- Check if a method is allowed for the current container.
- getMediaPart() : string
- Return media element (image, object, link) container name.
- setCollectionRelation() : void
- Set relation Id for elements that will be registered in the Collection subnamespaces.
- setMediaRelation() : void
- Set relation Id for media elements (link, image, object; legacy of OOXML).
Properties
$collectionRelation
Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.
protected
bool
$collectionRelation
= false
$commentsRangeEnd
The end position for the linked comments.
protected
Comments
$commentsRangeEnd
$commentsRangeStart
The start position for the linked comments.
protected
Comments
$commentsRangeStart
$container
Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange.
protected
string
$container
= 'Cell'
Container type
$docPart
Document part type: Section|Header|Footer|Footnote|Endnote.
protected
string
$docPart
= 'Section'
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.
$docPartId
Document part Id.
protected
int
$docPartId
= 1
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)
$elementId
Unique Id for element.
protected
string
$elementId
$elementIndex
Index of element in the elements collection (start with 1).
protected
int
$elementIndex
= 1
$elements
Elements collection.
protected
array<string|int, AbstractElement>
$elements
= []
$mediaRelation
Has media relation flag; true for Link, Image, and Object.
protected
bool
$mediaRelation
= false
$phpWord
PhpWord object.
protected
PhpWord|null
$phpWord
$relationId
Relation Id.
protected
int
$relationId
$sectionId
Section Id.
protected
int
$sectionId
$nestedLevel
Depth of table container nested level; Primarily used for RTF writer/reader.
private
int
$nestedLevel
= 0
0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc.
$parent
A reference to the parent.
private
null|AbstractElement
$parent
$parentContainer
Parent container type.
private
string
$parentContainer
$style
Cell style.
private
Cell|null
$style
$trackChange
changed element info.
private
TrackChange
$trackChange
$width
Cell width.
private
int|null
$width
Methods
__call()
Magic method to catch all 'addElement' variation.
public
__call(mixed $function, mixed $args) : AbstractElement
This removes addText, addTextRun, etc. When adding new element, we have to
add the model in the class docblock with @method
.
Warning: This makes capitalization matters, e.g. addCheckbox or addcheckbox won't work.
Parameters
- $function : mixed
- $args : mixed
Return values
AbstractElement__construct()
Create new instance.
public
__construct([null|int $width = null ][, array<string|int, mixed>|Cell $style = null ]) : mixed
Parameters
- $width : null|int = null
- $style : array<string|int, mixed>|Cell = null
addBookmark()
public
addBookmark([string $name = ]) : Bookmark
Parameters
- $name : string =
Return values
BookmarkaddChart()
public
addChart([string $type = ][, array<string|int, mixed> $categories = ][, array<string|int, mixed> $values = ][, array<string|int, mixed> $style = null ][, mixed $seriesName = null ]) : Chart
Parameters
- $type : string =
- $categories : array<string|int, mixed> =
- $values : array<string|int, mixed> =
- $style : array<string|int, mixed> = null
- $seriesName : mixed = null
Return values
ChartaddCheckBox()
public
addCheckBox([string $name = ][, mixed $text = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : CheckBox
Parameters
- $name : string =
- $text : mixed =
- $fStyle : mixed = null
- $pStyle : mixed = null
Return values
CheckBoxaddEndnote()
public
addEndnote([mixed $pStyle = null ]) : Endnote
Parameters
- $pStyle : mixed = null
Return values
EndnoteaddField()
public
addField([string $type = null ][, array<string|int, mixed> $properties = [] ][, array<string|int, mixed> $options = [] ][, mixed $text = null ]) : Field
Parameters
- $type : string = null
- $properties : array<string|int, mixed> = []
- $options : array<string|int, mixed> = []
- $text : mixed = null
Return values
FieldaddFootnote()
public
addFootnote([mixed $pStyle = null ]) : Footnote
Parameters
- $pStyle : mixed = null
Return values
FootnoteaddFormField()
public
addFormField([string $type = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : FormField
Parameters
- $type : string =
- $fStyle : mixed = null
- $pStyle : mixed = null
Return values
FormFieldaddFormula()
public
addFormula([Math $math = ]) : Formula
Parameters
- $math : Math =
Return values
FormulaaddImage()
public
addImage([string $source = ][, mixed $style = null ][, bool $isWatermark = false ][, mixed $name = null ]) : Image
Parameters
- $source : string =
- $style : mixed = null
- $isWatermark : bool = false
- $name : mixed = null
Return values
ImageaddLine()
public
addLine([mixed $lineStyle = null ]) : Line
Parameters
- $lineStyle : mixed = null
Return values
LineaddLink()
public
addLink([string $target = ][, string $text = null ][, mixed $fStyle = null ][, mixed $pStyle = null ][, bool $internal = false ]) : Link
Parameters
- $target : string =
- $text : string = null
- $fStyle : mixed = null
- $pStyle : mixed = null
- $internal : bool = false
Return values
LinkaddListItem()
public
addListItem([string $txt = ][, int $depth = 0 ][, mixed $font = null ][, mixed $list = null ][, mixed $para = null ]) : ListItem
Parameters
- $txt : string =
- $depth : int = 0
- $font : mixed = null
- $list : mixed = null
- $para : mixed = null
Return values
ListItemaddListItemRun()
public
addListItemRun([int $depth = 0 ][, mixed $listStyle = null ][, mixed $pStyle = null ]) : ListItemRun
Parameters
- $depth : int = 0
- $listStyle : mixed = null
- $pStyle : mixed = null
Return values
ListItemRunaddObject()
public
addObject([string $source = ][, mixed $style = null ]) : OLEObject
deprecated, use addOLEObject instead
Parameters
- $source : string =
- $style : mixed = null
Return values
OLEObjectaddOLEObject()
public
addOLEObject([string $source = ][, mixed $style = null ]) : OLEObject
Parameters
- $source : string =
- $style : mixed = null
Return values
OLEObjectaddPageBreak()
public
addPageBreak() : PageBreak
Return values
PageBreakaddPreserveText()
public
addPreserveText([string $text = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : PreserveText
Parameters
- $text : string =
- $fStyle : mixed = null
- $pStyle : mixed = null
Return values
PreserveTextaddSDT()
public
addSDT([string $type = ]) : SDT
Parameters
- $type : string =
Return values
SDTaddShape()
public
addShape([string $type = ][, mixed $style = null ]) : Shape
Parameters
- $type : string =
- $style : mixed = null
Return values
ShapeaddTable()
public
addTable([mixed $style = null ]) : Table
Parameters
- $style : mixed = null
Return values
TableaddText()
public
addText([string $text = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : Text
Parameters
- $text : string =
- $fStyle : mixed = null
- $pStyle : mixed = null
Return values
TextaddTextBox()
public
addTextBox([mixed $style = null ]) : TextBox
Parameters
- $style : mixed = null
Return values
TextBoxaddTextBreak()
public
addTextBreak([int $count = 1 ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : void
Parameters
- $count : int = 1
- $fStyle : mixed = null
- $pStyle : mixed = null
addTextRun()
public
addTextRun([mixed $pStyle = null ]) : TextRun
Parameters
- $pStyle : mixed = null
Return values
TextRunaddTitle()
public
addTitle([mixed $text = ][, int $depth = 1 ][, int $pageNumber = null ]) : Title
Parameters
- $text : mixed =
- $depth : int = 1
- $pageNumber : int = null
Return values
TitleaddTOC()
public
addTOC([mixed $fontStyle = null ][, mixed $tocStyle = null ][, int $minDepth = 1 ][, int $maxDepth = 9 ]) : TOC
Parameters
- $fontStyle : mixed = null
- $tocStyle : mixed = null
- $minDepth : int = 1
- $maxDepth : int = 9
Return values
TOCcountElements()
Count elements.
public
countElements() : int
Return values
intgetCommentRangeEnd()
Get comment end.
public
getCommentRangeEnd() : Comment
Return values
CommentgetCommentRangeStart()
Get comment start.
public
getCommentRangeStart() : Comment
Return values
CommentgetCommentsRangeEnd()
Get comments end.
public
getCommentsRangeEnd() : Comments
Return values
CommentsgetCommentsRangeStart()
Get comments start.
public
getCommentsRangeStart() : Comments
Return values
CommentsgetDocPart()
Get doc part.
public
getDocPart() : string
Return values
stringgetDocPartId()
Get doc part Id.
public
getDocPartId() : int
Return values
intgetElement()
Returns the element at the requested position.
public
getElement(int $index) : null|AbstractElement
Parameters
- $index : int
Return values
null|AbstractElementgetElementId()
Get element unique ID.
public
getElementId() : string
Return values
stringgetElementIndex()
Get element index.
public
getElementIndex() : int
Return values
intgetElements()
Get all elements.
public
getElements() : array<string|int, AbstractElement>
Return values
array<string|int, AbstractElement>getNestedLevel()
Get nested level.
public
getNestedLevel() : int
Return values
intgetParent()
Get parent element.
public
getParent() : null|AbstractElement
Return values
null|AbstractElementgetPhpWord()
Get PhpWord.
public
getPhpWord() : PhpWord|null
Return values
PhpWord|nullgetRelationId()
Get relation Id.
public
getRelationId() : int
Return values
intgetSectionId()
Get section number.
public
getSectionId() : int
Return values
intgetStyle()
Get cell style.
public
getStyle() : Cell|null
Return values
Cell|nullgetTrackChange()
Gets the trackChange information.
public
getTrackChange() : TrackChange
Return values
TrackChangegetWidth()
Get cell width.
public
getWidth() : int|null
Return values
int|nullisInSection()
Check if element is located in Section doc part (as opposed to Header/Footer).
public
isInSection() : bool
Return values
boolremoveElement()
Removes the element at requested index.
public
removeElement(int|AbstractElement $toRemove) : void
Parameters
- $toRemove : int|AbstractElement
setChangeInfo()
Set changed.
public
setChangeInfo(string $type, string $author[, null|DateTime|int $date = null ]) : void
Parameters
- $type : string
-
INSERTED|DELETED
- $author : string
- $date : null|DateTime|int = null
-
allways in UTC
setCommentRangeEnd()
Set comment end.
public
setCommentRangeEnd(Comment $value) : void
Parameters
- $value : Comment
setCommentRangeStart()
Set comment start.
public
setCommentRangeStart(Comment $value) : void
Parameters
- $value : Comment
setDocPart()
Set doc part.
public
setDocPart(string $docPart[, int $docPartId = 1 ]) : void
Parameters
- $docPart : string
- $docPartId : int = 1
setElementId()
Set element unique ID from 6 first digit of md5.
public
setElementId() : void
setElementIndex()
Set element index.
public
setElementIndex(int $value) : void
Parameters
- $value : int
setParentContainer()
Set parent container.
public
setParentContainer(self $container) : void
Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
Parameters
- $container : self
setPhpWord()
Set PhpWord as reference.
public
setPhpWord([PhpWord|null $phpWord = null ]) : void
Parameters
- $phpWord : PhpWord|null = null
setRelationId()
Set relation Id.
public
setRelationId(int $value) : void
Parameters
- $value : int
setTrackChange()
Sets the trackChange information.
public
setTrackChange(TrackChange $trackChange) : void
Parameters
- $trackChange : TrackChange
addElement()
Add element.
protected
addElement(string $elementName) : AbstractElement
Each element has different number of parameters passed
Parameters
- $elementName : string
Return values
AbstractElementsetEnumVal()
Set enum value.
protected
setEnumVal([null|string $value = null ][, array<string|int, string> $enum = [] ][, null|string $default = null ]) : null|string
Parameters
- $value : null|string = null
- $enum : array<string|int, string> = []
- $default : null|string = null
Tags
Return values
null|stringsetNewStyle()
Set new style value.
protected
setNewStyle(mixed $styleObject[, null|array<string|int, mixed>|string|Style $styleValue = null ][, bool $returnObject = false ]) : mixed
Parameters
- $styleObject : mixed
-
Style object
- $styleValue : null|array<string|int, mixed>|string|Style = null
-
Style value
- $returnObject : bool = false
-
Always return object
checkValidity()
Check if a method is allowed for the current container.
private
checkValidity(string $method) : bool
Parameters
- $method : string
Return values
boolgetMediaPart()
Return media element (image, object, link) container name.
private
getMediaPart() : string
Return values
string —section|headerx|footerx|footnote|endnote
setCollectionRelation()
Set relation Id for elements that will be registered in the Collection subnamespaces.
private
setCollectionRelation() : void
setMediaRelation()
Set relation Id for media elements (link, image, object; legacy of OOXML).
private
setMediaRelation() : void
- Image element needs to be passed to Media object
- Icon needs to be set for Object element