Documentation

Style extends Supervisor
in package

Table of Contents

Properties

$alignment  : Alignment
Alignment.
$borders  : Borders
Borders.
$fill  : Fill
Fill.
$font  : Font
Font.
$index  : int
Index of style in collection. Only used for real style.
$isSupervisor  : bool
Supervisor?
$numberFormat  : NumberFormat
Number Format.
$parent  : Spreadsheet|Supervisor
Parent. Only used for supervisor.
$parentPropertyName  : string|null
Parent property name.
$protection  : Protection
Protection.
$quotePrefix  : bool
Use Quote Prefix when displaying in cell editor. Only used for real style.
$cachedStyles  : null|array<string, array<string|int, mixed>>
Internal cache for styles Used when applying style on range of cells (column or row) and cleared when all cells in range is styled.

Methods

__clone()  : mixed
Implement PHP __clone to create a deep clone, not just a shallow copy.
__construct()  : mixed
Create a new Style.
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.
getAlignment()  : Alignment
Get Alignment.
getBorders()  : Borders
Get Borders.
getConditionalStyles()  : array<string|int, Conditional>
Get Conditional Styles. Only used on supervisor.
getFill()  : Fill
Get Fill.
getFont()  : Font
Get Font.
getHashCode()  : string
Get hash code.
getIndex()  : int
Get own index in style collection.
getIsSupervisor()  : bool
Is this a supervisor or a cell style component?
getNumberFormat()  : NumberFormat
Get Number Format.
getParent()  : Spreadsheet
Get parent. Only used for style supervisor.
getProtection()  : Protection
Get Protection.
getQuotePrefix()  : bool
Get quote prefix.
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.
getStyleArray()  : array<string|int, mixed>
Build style array from subcomponents.
setConditionalStyles()  : $this
Set Conditional Styles. Only used on supervisor.
setFont()  : $this
Set font.
setIndex()  : void
Set own index in style collection.
setQuotePrefix()  : $this
Set quote prefix.
exportArray1()  : array<string|int, mixed>
Abstract method to be implemented in anything which extends this class.
exportArray2()  : void
Populate array from exportArray1.
getOldXfIndexes()  : array<string|int, mixed>

Properties

$index

Index of style in collection. Only used for real style.

protected int $index

$isSupervisor

Supervisor?

protected bool $isSupervisor

$parentPropertyName

Parent property name.

protected string|null $parentPropertyName = null

$quotePrefix

Use Quote Prefix when displaying in cell editor. Only used for real style.

protected bool $quotePrefix = false

$cachedStyles

Internal cache for styles Used when applying style on range of cells (column or row) and cleared when all cells in range is styled.

private static null|array<string, array<string|int, mixed>> $cachedStyles = null

PhpSpreadsheet will always minimize the amount of styles used. So cells with same styles will reference the same Style instance. To check if two styles are similar Style::getHashCode() is used. This call is expensive. To minimize the need to call this method we can cache the internal PHP object id of the Style in the range. Style::getHashCode() will then only be called when we encounter a unique style.

Tags
see
Style::applyFromArray()
see
Style::getHashCode()

Methods

__clone()

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

public __clone() : mixed

__construct()

Create a new Style.

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[, bool $advancedBorders = true ]) : $this
$spreadsheet->getActiveSheet()->getStyle('B2')->applyFromArray( [ 'font' => [ 'name' => 'Arial', 'bold' => true, 'italic' => false, 'underline' => Font::UNDERLINE_DOUBLE, 'strikethrough' => false, 'color' => [ 'rgb' => '808080' ] ], 'borders' => [ 'bottom' => [ 'borderStyle' => Border::BORDER_DASHDOT, 'color' => [ 'rgb' => '808080' ] ], 'top' => [ 'borderStyle' => Border::BORDER_DASHDOT, 'color' => [ 'rgb' => '808080' ] ] ], 'alignment' => [ 'horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER, 'wrapText' => true, ], 'quotePrefix' => true ] );
Parameters
$styleArray : array<string|int, mixed>

Array containing style information

$advancedBorders : bool = true

advanced mode for setting borders

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'

getConditionalStyles()

Get Conditional Styles. Only used on supervisor.

public getConditionalStyles() : array<string|int, Conditional>
Return values
array<string|int, Conditional>

getHashCode()

Get hash code.

public getHashCode() : string
Return values
string

Hash code

getIndex()

Get own index in style collection.

public getIndex() : int
Return values
int

getIsSupervisor()

Is this a supervisor or a cell style component?

public getIsSupervisor() : bool
Return values
bool

getQuotePrefix()

Get quote prefix.

public getQuotePrefix() : bool
Return values
bool

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

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>

setConditionalStyles()

Set Conditional Styles. Only used on supervisor.

public setConditionalStyles(array<string|int, Conditional$conditionalStyleArray) : $this
Parameters
$conditionalStyleArray : array<string|int, Conditional>

Array of conditional styles

Return values
$this

setFont()

Set font.

public setFont(Font $font) : $this
Parameters
$font : Font
Return values
$this

setIndex()

Set own index in style collection.

public setIndex(int $index) : void
Parameters
$index : int

setQuotePrefix()

Set quote prefix.

public setQuotePrefix(bool $quotePrefix) : $this
Parameters
$quotePrefix : bool
Return values
$this

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

getOldXfIndexes()

private getOldXfIndexes(string $selectionType, array<string|int, mixed> $rangeStart, array<string|int, mixed> $rangeEnd, string $columnStart, string $columnEnd, array<string|int, mixed> $styleArray) : array<string|int, mixed>
Parameters
$selectionType : string
$rangeStart : array<string|int, mixed>
$rangeEnd : array<string|int, mixed>
$columnStart : string
$columnEnd : string
$styleArray : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results