Style extends Supervisor
Table of Contents
- $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 : null|string
- 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.
- __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() : mixed
- 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
$alignment
Alignment.
protected
Alignment
$alignment
$borders
Borders.
protected
Borders
$borders
$fill
Fill.
protected
Fill
$fill
$font
Font.
protected
Font
$font
$index
Index of style in collection. Only used for real style.
protected
int
$index
$isSupervisor
Supervisor?
protected
bool
$isSupervisor
$numberFormat
Number Format.
protected
NumberFormat
$numberFormat
$parent
Parent. Only used for supervisor.
protected
Spreadsheet|Supervisor
$parent
$parentPropertyName
Parent property name.
protected
null|string
$parentPropertyName
$protection
Protection.
protected
Protection
$protection
$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
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
Methods
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
public
__clone() : mixed
Return values
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
Return values
mixed —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|Supervisor $parent[, null|string $parentPropertyName = null ]) : $this
Parameters
- $parent : Spreadsheet|Supervisor
- $parentPropertyName : null|string = 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'
getActiveSheet()
Get the currently active sheet. Only used for supervisor.
public
getActiveSheet() : Worksheet
Return values
Worksheet —getAlignment()
Get Alignment.
public
getAlignment() : Alignment
Return values
Alignment —getBorders()
Get Borders.
public
getBorders() : Borders
Return values
Borders —getConditionalStyles()
Get Conditional Styles. Only used on supervisor.
public
getConditionalStyles() : array<string|int, Conditional>
Return values
array<string|int, Conditional> —getFill()
Get Fill.
public
getFill() : Fill
Return values
Fill —getFont()
Get Font.
public
getFont() : Font
Return values
Font —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 —getNumberFormat()
Get Number Format.
public
getNumberFormat() : NumberFormat
Return values
NumberFormat —getParent()
Get parent. Only used for style supervisor.
public
getParent() : Spreadsheet
Return values
Spreadsheet —getProtection()
Get Protection.
public
getProtection() : Protection
Return values
Protection —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() : mixed
Only used for style supervisor.
Return values
mixed —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
Return values
void —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
Return values
void —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>