class Font extends Supervisor (View source)

Constants

UNDERLINE_NONE

UNDERLINE_DOUBLE

UNDERLINE_DOUBLEACCOUNTING

UNDERLINE_SINGLE

UNDERLINE_SINGLEACCOUNTING

Properties

protected bool $isSupervisor Supervisor? from Supervisor
protected Spreadsheet|Style $parent Parent. Only used for supervisor. from Supervisor
protected null|string $parentPropertyName Parent property name. from Supervisor
protected string $name Font Name.
protected float $size Font Size.
protected bool $bold Bold.
protected bool $italic Italic.
protected bool $superscript Superscript.
protected bool $subscript Subscript.
protected string $underline Underline.
protected bool $strikethrough Strikethrough.
protected Color $color Foreground color.
int $colorIndex

Methods

__construct(bool $isSupervisor = false, bool $isConditional = false)

Create a new Font.

bindParent(Spreadsheet|Style $parent, null|string $parentPropertyName = null)

Bind parent. Only used for supervisor.

bool
getIsSupervisor()

Is this a supervisor or a cell style component?

getActiveSheet()

Get the currently active sheet. Only used for supervisor.

string
getSelectedCells()

Get the currently active cell coordinate in currently active sheet.

string
getActiveCell()

Get the currently active cell coordinate in currently active sheet.

__clone()

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

getSharedComponent()

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

array
getStyleArray(array $array)

Build style array from subcomponents.

applyFromArray(array $pStyles)

Apply styles from array.

string
getName()

Get Name.

setName(string $pValue)

Set Name.

float
getSize()

Get Size.

setSize(float $pValue)

Set Size.

bool
getBold()

Get Bold.

setBold(bool $pValue)

Set Bold.

bool
getItalic()

Get Italic.

setItalic(bool $pValue)

Set Italic.

bool
getSuperscript()

Get Superscript.

setSuperscript(bool $pValue)

Set Superscript.

bool
getSubscript()

Get Subscript.

setSubscript(bool $pValue)

Set Subscript.

string
getUnderline()

Get Underline.

setUnderline(bool|string $pValue)

Set Underline.

bool
getStrikethrough()

Get Strikethrough.

setStrikethrough(bool $pValue)

Set Strikethrough.

getColor()

Get Color.

setColor(Color $pValue)

Set Color.

string
getHashCode()

Get hash code.

Details

__construct(bool $isSupervisor = false, bool $isConditional = false)

Create a new Font.

Parameters

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

Supervisor bindParent(Spreadsheet|Style $parent, null|string $parentPropertyName = null)

Bind parent. Only used for supervisor.

Parameters

Spreadsheet|Style $parent
null|string $parentPropertyName

Return Value

Supervisor

bool getIsSupervisor()

Is this a supervisor or a cell style component?

Return Value

bool

Worksheet getActiveSheet()

Get the currently active sheet. Only used for supervisor.

Return Value

Worksheet

string getSelectedCells()

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Return Value

string E.g. 'A1'

string getActiveCell()

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Return Value

string E.g. 'A1'

__clone()

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

Font getSharedComponent()

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

Only used for style supervisor.

Return Value

Font

array getStyleArray(array $array)

Build style array from subcomponents.

Parameters

array $array

Return Value

array

Font applyFromArray(array $pStyles)

Apply styles from array.

$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

array $pStyles Array containing style information

Return Value

Font

Exceptions

Exception

string getName()

Get Name.

Return Value

string

Font setName(string $pValue)

Set Name.

Parameters

string $pValue

Return Value

Font

float getSize()

Get Size.

Return Value

float

Font setSize(float $pValue)

Set Size.

Parameters

float $pValue

Return Value

Font

bool getBold()

Get Bold.

Return Value

bool

Font setBold(bool $pValue)

Set Bold.

Parameters

bool $pValue

Return Value

Font

bool getItalic()

Get Italic.

Return Value

bool

Font setItalic(bool $pValue)

Set Italic.

Parameters

bool $pValue

Return Value

Font

bool getSuperscript()

Get Superscript.

Return Value

bool

Font setSuperscript(bool $pValue)

Set Superscript.

Parameters

bool $pValue

Return Value

Font

bool getSubscript()

Get Subscript.

Return Value

bool

Font setSubscript(bool $pValue)

Set Subscript.

Parameters

bool $pValue

Return Value

Font

string getUnderline()

Get Underline.

Return Value

string

Font setUnderline(bool|string $pValue)

Set Underline.

Parameters

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

Return Value

Font

bool getStrikethrough()

Get Strikethrough.

Return Value

bool

Font setStrikethrough(bool $pValue)

Set Strikethrough.

Parameters

bool $pValue

Return Value

Font

Color getColor()

Get Color.

Return Value

Color

Font setColor(Color $pValue)

Set Color.

Parameters

Color $pValue

Return Value

Font

Exceptions

Exception

string getHashCode()

Get hash code.

Return Value

string Hash code