Documentation

PhpWord

PHPWord main class

Table of Contents

DEFAULT_FONT_COLOR  = PhpOfficePhpWordSettings::DEFAULT_FONT_COLOR
DEFAULT_FONT_CONTENT_TYPE  = PhpOfficePhpWordSettings::DEFAULT_FONT_CONTENT_TYPE
DEFAULT_FONT_NAME  = PhpOfficePhpWordSettings::DEFAULT_FONT_NAME
Default font settings
DEFAULT_FONT_SIZE  = PhpOfficePhpWordSettings::DEFAULT_FONT_SIZE
$collections  : array<string|int, mixed>
Collections
$metadata  : array<string|int, mixed>
Metadata
$sections  : array<string|int, Section>
Collection of sections
__call()  : mixed
Dynamic function call to reduce static dependency
__construct()  : mixed
Create new instance
addBookmark()  :
addChart()  :
addComment()  :
addEndnote()  :
addFontStyle()  :
addFootnote()  :
addLinkStyle()  :
addNumberingStyle()  :
addParagraphStyle()  :
addSection()  : Section
Create new section
addTableStyle()  :
addTitle()  :
addTitleStyle()  :
createSection()  : Section
Create new section
getCharts()  :
getComments()  :
getCompatibility()  : Compatibility
Get compatibility
getDefaultFontName()  : string
Get default font name
getDefaultFontSize()  : int
Get default font size
getDocInfo()  : DocInfo
Get document properties object
getDocumentProperties()  : DocInfo
Get document properties object
getEndnotes()  :
getFootnotes()  :
getProtection()  : Protection
Get protection
getSection()  : Section|null
Returns the section at the requested position
getSections()  : array<string|int, Section>
Get all sections
getSettings()  : Settings
Get compatibility
getTitles()  :
loadTemplate()  : TemplateProcessor
Load template by filename
save()  : bool
Save to file or download
setDefaultFontName()  : mixed
Set default font name.
setDefaultFontSize()  : mixed
Set default font size.
setDefaultParagraphStyle()  : Paragraph
Set default paragraph style definition to styles.xml
setDocumentProperties()  : self
Set document properties object
sortSections()  : mixed
Sorts the sections using the callable passed

Constants

DEFAULT_FONT_COLOR

public mixed DEFAULT_FONT_COLOR = PhpOfficePhpWordSettings::DEFAULT_FONT_COLOR
Tags
deprecated
0.11.0

Use Settings constants

DEFAULT_FONT_CONTENT_TYPE

public mixed DEFAULT_FONT_CONTENT_TYPE = PhpOfficePhpWordSettings::DEFAULT_FONT_CONTENT_TYPE
Tags
deprecated
0.11.0

Use Settings constants

DEFAULT_FONT_NAME

Default font settings

public mixed DEFAULT_FONT_NAME = PhpOfficePhpWordSettings::DEFAULT_FONT_NAME
Tags
deprecated
0.11.0

Use Settings constants

const

string|int

DEFAULT_FONT_SIZE

public mixed DEFAULT_FONT_SIZE = PhpOfficePhpWordSettings::DEFAULT_FONT_SIZE
Tags
deprecated
0.11.0

Use Settings constants

Properties

$collections

Collections

private array<string|int, mixed> $collections = array()

$metadata

Metadata

private array<string|int, mixed> $metadata = array()
Tags
since
0.12.0

$sections

Collection of sections

private array<string|int, Section> $sections = array()

Methods

__call()

Dynamic function call to reduce static dependency

public __call(mixed $function, mixed $args) : mixed
Parameters
$function : mixed
$args : mixed
Tags
since
0.12.0
throws
BadMethodCallException
Return values
mixed

__construct()

Create new instance

public __construct() : mixed

Collections are created dynamically

Return values
mixed

addChart()

public addChart(Chart $chart) :
Parameters
$chart : Chart
Return values

addFontStyle()

public addFontStyle(string $styleName, mixed $fontStyle, mixed $paragraphStyle = null) :
Parameters
$styleName : string
$fontStyle : mixed
$paragraphStyle = null : mixed
Return values

addLinkStyle()

public addLinkStyle(string $styleName, mixed $styles) :
Parameters
$styleName : string
$styles : mixed
Return values

addNumberingStyle()

public addNumberingStyle(string $styleName, mixed $styles) :
Parameters
$styleName : string
$styles : mixed
Return values

addParagraphStyle()

public addParagraphStyle(string $styleName, mixed $styles) :
Parameters
$styleName : string
$styles : mixed
Return values

addSection()

Create new section

public addSection([array<string|int, mixed> $style = null ]) : Section
Parameters
$style : array<string|int, mixed> = null
Return values
Section

addTableStyle()

public addTableStyle(string $styleName, mixed $styleTable, mixed $styleFirstRow = null) :
Parameters
$styleName : string
$styleTable : mixed
$styleFirstRow = null : mixed
Return values

addTitle()

public addTitle(Title $title) :
Parameters
$title : Title
Return values

addTitleStyle()

public addTitleStyle(mixed $depth, mixed $fontStyle, mixed $paragraphStyle = null) :
Parameters
$depth : mixed
$fontStyle : mixed
$paragraphStyle = null : mixed
Return values

createSection()

Create new section

public createSection([array<string|int, mixed> $settings = null ]) : Section
Parameters
$settings : array<string|int, mixed> = null
Tags
deprecated
0.10.0
codeCoverageIgnore
Return values
Section

getCharts()

public getCharts() :
Return values

getComments()

public getComments() :
Return values

getDefaultFontName()

Get default font name

public getDefaultFontName() : string
Return values
string

getDefaultFontSize()

Get default font size

public getDefaultFontSize() : int
Return values
int

getDocumentProperties()

Get document properties object

public getDocumentProperties() : DocInfo
Tags
deprecated
0.12.0
codeCoverageIgnore
Return values
DocInfo

getEndnotes()

public getEndnotes() :
Return values

getFootnotes()

public getFootnotes() :
Return values

getProtection()

Get protection

public getProtection() : Protection
Tags
since
0.12.0
deprecated

Get the Document protection from PhpWord->getSettings()->getDocumentProtection();

codeCoverageIgnore
Return values
Protection

getSection()

Returns the section at the requested position

public getSection(int $index) : Section|null
Parameters
$index : int
Return values
Section|null

getSections()

Get all sections

public getSections() : array<string|int, Section>
Return values
array<string|int, Section>

getTitles()

public getTitles() :
Return values

loadTemplate()

Load template by filename

public loadTemplate(string $filename) : TemplateProcessor
Parameters
$filename : string

Fully qualified filename

Tags
deprecated
0.12.0

Use new TemplateProcessor($documentTemplate) instead.

throws
Exception
codeCoverageIgnore
Return values
TemplateProcessor

save()

Save to file or download

public save(string $filename[, string $format = 'Word2007' ][, bool $download = false ]) : bool

All exceptions should already been handled by the writers

Parameters
$filename : string
$format : string = 'Word2007'
$download : bool = false
Return values
bool

setDefaultFontName()

Set default font name.

public setDefaultFontName(string $fontName) : mixed
Parameters
$fontName : string
Return values
mixed

setDefaultFontSize()

Set default font size.

public setDefaultFontSize(int $fontSize) : mixed
Parameters
$fontSize : int
Return values
mixed

setDefaultParagraphStyle()

Set default paragraph style definition to styles.xml

public setDefaultParagraphStyle(array<string|int, mixed> $styles) : Paragraph
Parameters
$styles : array<string|int, mixed>

Paragraph style definition

Return values
Paragraph

setDocumentProperties()

Set document properties object

public setDocumentProperties(DocInfo $documentProperties) : self
Parameters
$documentProperties : DocInfo
Tags
deprecated
0.12.0
codeCoverageIgnore
Return values
self

Search results