Documentation

Font extends Supervisor
in package

Table of Contents

Constants

CAP_ALL  = 'all'
CAP_NONE  = 'none'
CAP_SMALL  = 'small'
DEFAULT_FONT_NAME  = 'Calibri'
UNDERLINE_DOUBLE  = 'double'
UNDERLINE_DOUBLEACCOUNTING  = 'doubleAccounting'
UNDERLINE_NONE  = 'none'
UNDERLINE_SINGLE  = 'single'
UNDERLINE_SINGLEACCOUNTING  = 'singleAccounting'
VALID_CAPS  = [self::CAP_ALL, self::CAP_SMALL, self::CAP_NONE]

Properties

$colorIndex  : int|null
$bold  : bool|null
Bold.
$cap  : string|null
$color  : Color
Foreground color.
$isSupervisor  : bool
Supervisor?
$italic  : bool|null
Italic.
$name  : string|null
Font Name.
$parent  : Spreadsheet|Supervisor
Parent. Only used for supervisor.
$parentPropertyName  : string|null
Parent property name.
$scheme  : string
$size  : float|null
Font Size.
$strikethrough  : bool|null
Strikethrough.
$subscript  : bool|null
Subscript.
$superscript  : bool|null
Superscript.
$underline  : string|null
Underline.
$baseLine  : int
$chartColor  : ChartColor|null
$complexScript  : string
$eastAsian  : string
$latin  : string
The following 7 are used only for chart titles, I think.
$strikeType  : string
$underlineColor  : ChartColor|null

Methods

__clone()  : mixed
Implement PHP __clone to create a deep clone, not just a shallow copy.
__construct()  : mixed
Create a new Font.
applyFromArray()  : $this
Apply styles from array.
bindParent()  : $this
Bind parent. Only used for supervisor.
exportArray()  : array<string|int, mixed>
Export style as array.
getActiveCell()  : string
Get the currently active cell coordinate in currently active sheet.
getActiveSheet()  : Worksheet
Get the currently active sheet. Only used for supervisor.
getBaseLine()  : int
getBold()  : bool|null
Get Bold.
getCap()  : string|null
getChartColor()  : ChartColor|null
getColor()  : Color
Get Color.
getComplexScript()  : string
getEastAsian()  : string
getHashCode()  : string
Get hash code.
getIsSupervisor()  : bool
Is this a supervisor or a cell style component?
getItalic()  : bool|null
Get Italic.
getLatin()  : string
getName()  : string|null
Get Name.
getScheme()  : string
getSelectedCells()  : string
Get the currently active cell coordinate in currently active sheet.
getSharedComponent()  : self
Get the shared style component for the currently active cell in currently active sheet.
getSize()  : float|null
Get Size.
getStrikethrough()  : bool|null
Get Strikethrough.
getStrikeType()  : string
getStyleArray()  : array<string|int, mixed>
Build style array from subcomponents.
getSubscript()  : bool|null
Get Subscript.
getSuperscript()  : bool|null
Get Superscript.
getUnderline()  : string|null
Get Underline.
getUnderlineColor()  : ChartColor|null
setBaseLine()  : self
setBold()  : $this
Set Bold.
setCap()  : self
Set capitalization attribute. If not one of the permitted values (all, small, or none), set it to null.
setChartColor()  : self
setChartColorFromObject()  : self
setColor()  : $this
Set Color.
setComplexScript()  : self
setEastAsian()  : self
setItalic()  : $this
Set Italic.
setLatin()  : self
setName()  : self
Set Name and turn off Scheme.
setScheme()  : self
setSize()  : $this
Set Size.
setStrikethrough()  : $this
Set Strikethrough.
setStrikeType()  : self
setSubscript()  : $this
Set Subscript.
setSuperscript()  : $this
Set Superscript.
setUnderline()  : $this
Set Underline.
setUnderlineColor()  : self
exportArray1()  : array<string|int, mixed>
Abstract method to be implemented in anything which extends this class.
exportArray2()  : void
Populate array from exportArray1.
hashChartColor()  : string

Constants

CAP_ALL

public mixed CAP_ALL = 'all'

CAP_NONE

public mixed CAP_NONE = 'none'

CAP_SMALL

public mixed CAP_SMALL = 'small'

DEFAULT_FONT_NAME

public mixed DEFAULT_FONT_NAME = 'Calibri'

UNDERLINE_DOUBLE

public mixed UNDERLINE_DOUBLE = 'double'

UNDERLINE_DOUBLEACCOUNTING

public mixed UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting'

UNDERLINE_NONE

public mixed UNDERLINE_NONE = 'none'

UNDERLINE_SINGLE

public mixed UNDERLINE_SINGLE = 'single'

UNDERLINE_SINGLEACCOUNTING

public mixed UNDERLINE_SINGLEACCOUNTING = 'singleAccounting'

VALID_CAPS

private mixed VALID_CAPS = [self::CAP_ALL, self::CAP_SMALL, self::CAP_NONE]

Properties

$colorIndex

public int|null $colorIndex = null

$bold

Bold.

protected bool|null $bold = false

$cap

protected string|null $cap = null

$isSupervisor

Supervisor?

protected bool $isSupervisor

$italic

Italic.

protected bool|null $italic = false

$name

Font Name.

protected string|null $name = self::DEFAULT_FONT_NAME

$parentPropertyName

Parent property name.

protected string|null $parentPropertyName = null

$scheme

protected string $scheme = ''

$size

Font Size.

protected float|null $size = 11

$strikethrough

Strikethrough.

protected bool|null $strikethrough = false

$subscript

Subscript.

protected bool|null $subscript = false

$superscript

Superscript.

protected bool|null $superscript = false

$underline

Underline.

protected string|null $underline = self::UNDERLINE_NONE

$baseLine

private int $baseLine = 0

$complexScript

private string $complexScript = ''

$eastAsian

private string $eastAsian = ''

$latin

The following 7 are used only for chart titles, I think.

private string $latin = ''

$strikeType

private string $strikeType = ''

Methods

__clone()

Implement PHP __clone to create a deep clone, not just a shallow copy.

public __clone() : mixed

__construct()

Create a new Font.

public __construct([bool $isSupervisor = false ][, bool $isConditional = false ]) : mixed
Parameters
$isSupervisor : bool = false

Flag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are

$isConditional : bool = false

Flag indicating if this is a conditional style or not Leave this value at default unless you understand exactly what its ramifications are

applyFromArray()

Apply styles from array.

public applyFromArray(array<string|int, mixed> $styleArray) : $this
$spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray( [ 'name' => 'Arial', 'bold' => TRUE, 'italic' => FALSE, 'underline' => \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE, 'strikethrough' => FALSE, 'color' => [ 'rgb' => '808080' ] ] );
Parameters
$styleArray : array<string|int, mixed>

Array containing style information

Return values
$this

bindParent()

Bind parent. Only used for supervisor.

public bindParent(Spreadsheet|self $parent[, string|null $parentPropertyName = null ]) : $this
Parameters
$parent : Spreadsheet|self
$parentPropertyName : string|null = null
Return values
$this

exportArray()

Export style as array.

public final exportArray() : array<string|int, mixed>

Available to anything which extends this class: Alignment, Border, Borders, Color, Fill, Font, NumberFormat, Protection, and Style.

Return values
array<string|int, mixed>

getActiveCell()

Get the currently active cell coordinate in currently active sheet.

public getActiveCell() : string

Only used for supervisor.

Return values
string

E.g. 'A1'

getBaseLine()

public getBaseLine() : int
Return values
int

getBold()

Get Bold.

public getBold() : bool|null
Return values
bool|null

getCap()

public getCap() : string|null
Return values
string|null

getComplexScript()

public getComplexScript() : string
Return values
string

getEastAsian()

public getEastAsian() : string
Return values
string

getHashCode()

Get hash code.

public getHashCode() : string
Return values
string

Hash code

getIsSupervisor()

Is this a supervisor or a cell style component?

public getIsSupervisor() : bool
Return values
bool

getItalic()

Get Italic.

public getItalic() : bool|null
Return values
bool|null

getLatin()

public getLatin() : string
Return values
string

getName()

Get Name.

public getName() : string|null
Return values
string|null

getScheme()

public getScheme() : string
Return values
string

getSelectedCells()

Get the currently active cell coordinate in currently active sheet.

public getSelectedCells() : string

Only used for supervisor.

Return values
string

E.g. 'A1'

getSharedComponent()

Get the shared style component for the currently active cell in currently active sheet.

public getSharedComponent() : self

Only used for style supervisor.

Return values
self

getSize()

Get Size.

public getSize() : float|null
Return values
float|null

getStrikethrough()

Get Strikethrough.

public getStrikethrough() : bool|null
Return values
bool|null

getStrikeType()

public getStrikeType() : string
Return values
string

getStyleArray()

Build style array from subcomponents.

public getStyleArray(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
Return values
array<string|int, mixed>

getSubscript()

Get Subscript.

public getSubscript() : bool|null
Return values
bool|null

getSuperscript()

Get Superscript.

public getSuperscript() : bool|null
Return values
bool|null

getUnderline()

Get Underline.

public getUnderline() : string|null
Return values
string|null

setBaseLine()

public setBaseLine(int $baseLine) : self
Parameters
$baseLine : int
Return values
self

setBold()

Set Bold.

public setBold(bool $bold) : $this
Parameters
$bold : bool
Return values
$this

setCap()

Set capitalization attribute. If not one of the permitted values (all, small, or none), set it to null.

public setCap(string $cap) : self

This will be honored only for the font for chart titles. None is distinguished from null because null will inherit the current value, whereas 'none' will override it.

Parameters
$cap : string
Return values
self

setChartColor()

public setChartColor(array<string|int, mixed> $colorArray) : self
Parameters
$colorArray : array<string|int, mixed>
Return values
self

setChartColorFromObject()

public setChartColorFromObject(ChartColor|null $chartColor) : self
Parameters
$chartColor : ChartColor|null
Return values
self

setColor()

Set Color.

public setColor(Color $color) : $this
Parameters
$color : Color
Return values
$this

setComplexScript()

public setComplexScript(string $fontname) : self
Parameters
$fontname : string
Return values
self

setEastAsian()

public setEastAsian(string $fontname) : self
Parameters
$fontname : string
Return values
self

setItalic()

Set Italic.

public setItalic(bool $italic) : $this
Parameters
$italic : bool
Return values
$this

setLatin()

public setLatin(string $fontname) : self
Parameters
$fontname : string
Return values
self

setName()

Set Name and turn off Scheme.

public setName(string $fontname) : self
Parameters
$fontname : string
Return values
self

setScheme()

public setScheme(string $scheme) : self
Parameters
$scheme : string
Return values
self

setSize()

Set Size.

public setSize(mixed $sizeInPoints[, bool $nullOk = false ]) : $this
Parameters
$sizeInPoints : mixed

A float representing the value of a positive measurement in points (1/72 of an inch)

$nullOk : bool = false
Return values
$this

setStrikethrough()

Set Strikethrough.

public setStrikethrough(bool $strikethru) : $this
Parameters
$strikethru : bool
Return values
$this

setStrikeType()

public setStrikeType(string $strikeType) : self
Parameters
$strikeType : string
Return values
self

setSubscript()

Set Subscript.

public setSubscript(bool $subscript) : $this
Parameters
$subscript : bool
Return values
$this

setSuperscript()

Set Superscript.

public setSuperscript(bool $superscript) : $this
Parameters
$superscript : bool
Return values
$this

setUnderline()

Set Underline.

public setUnderline(bool|string $underlineStyle) : $this
Parameters
$underlineStyle : bool|string

\PhpOffice\PhpSpreadsheet\Style\Font underline type If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE, false equates to UNDERLINE_NONE

Return values
$this

setUnderlineColor()

public setUnderlineColor(array<string|int, mixed> $colorArray) : self
Parameters
$colorArray : array<string|int, mixed>
Return values
self

exportArray1()

Abstract method to be implemented in anything which extends this class.

protected exportArray1() : array<string|int, mixed>

This method invokes exportArray2 with the names and values of all properties to be included in output array, returning that array to exportArray, then to caller.

Return values
array<string|int, mixed>

exportArray2()

Populate array from exportArray1.

protected final exportArray2(array<string|int, mixed> &$exportedArray, string $index, mixed $objOrValue) : void

This method is available to anything which extends this class. The parameter index is the key to be added to the array. The parameter objOrValue is either a primitive type, which is the value added to the array, or a Style object to be recursively added via exportArray.

Parameters
$exportedArray : array<string|int, mixed>
$index : string
$objOrValue : mixed

hashChartColor()

private hashChartColor(ChartColor|null $underlineColor) : string
Parameters
$underlineColor : ChartColor|null
Return values
string

        
On this page

Search results