Documentation

Color extends Supervisor
in package

Table of Contents

Constants

COLOR_BLACK  = 'FF000000'
COLOR_BLUE  = 'FF0000FF'
COLOR_CYAN  = 'FF00FFFF'
COLOR_DARKBLUE  = 'FF000080'
COLOR_DARKGREEN  = 'FF008000'
COLOR_DARKRED  = 'FF800000'
COLOR_DARKYELLOW  = 'FF808000'
COLOR_GREEN  = 'FF00FF00'
COLOR_MAGENTA  = 'FFFF00FF'
COLOR_RED  = 'FFFF0000'
COLOR_WHITE  = 'FFFFFFFF'
COLOR_YELLOW  = 'FFFFFF00'
NAMED_COLOR_TRANSLATIONS  = ['Black' => self::COLOR_BLACK, 'White' => self::COLOR_WHITE, 'Red' => self::COLOR_RED, 'Green' => self::COLOR_GREEN, 'Blue' => self::COLOR_BLUE, 'Yellow' => self::COLOR_YELLOW, 'Magenta' => self::COLOR_MAGENTA, 'Cyan' => self::COLOR_CYAN]
NAMED_COLORS  = ['Black', 'White', 'Red', 'Green', 'Blue', 'Yellow', 'Magenta', 'Cyan']
VALIDATE_ARGB_SIZE  = 8
VALIDATE_COLOR_6  = '/^[A-F0-9]{6}$/i'
VALIDATE_COLOR_8  = '/^[A-F0-9]{8}$/i'
VALIDATE_RGB_SIZE  = 6

Properties

$argb  : string|null
ARGB - Alpha RGB.
$isSupervisor  : bool
Supervisor?
$parent  : Spreadsheet|Supervisor
Parent. Only used for supervisor.
$parentPropertyName  : string|null
Parent property name.

Methods

__clone()  : mixed
Implement PHP __clone to create a deep clone, not just a shallow copy.
__construct()  : mixed
Create a new Color.
applyFromArray()  : $this
Apply styles from array.
bindParent()  : $this
Bind parent. Only used for supervisor.
changeBrightness()  : string
Adjust the brightness of a color.
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.
getARGB()  : string|null
Get ARGB.
getBlue()  : int|string
Get the blue colour component of an RGB value.
getGreen()  : int|string
Get the green colour component of an RGB value.
getHasChanged()  : bool
getHashCode()  : string
Get hash code.
getIsSupervisor()  : bool
Is this a supervisor or a cell style component?
getRed()  : int|string
Get the red colour component of an RGB value.
getRGB()  : string
Get RGB.
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.
getTheme()  : int
indexedColor()  : self
Get indexed color.
setARGB()  : $this
Set ARGB.
setHyperlinkTheme()  : self
setRGB()  : $this
Set RGB.
setTheme()  : self
exportArray1()  : array<string|int, mixed>
Abstract method to be implemented in anything which extends this class.
exportArray2()  : void
Populate array from exportArray1.

Constants

COLOR_BLACK

public mixed COLOR_BLACK = 'FF000000'

COLOR_BLUE

public mixed COLOR_BLUE = 'FF0000FF'

COLOR_CYAN

public mixed COLOR_CYAN = 'FF00FFFF'

COLOR_DARKBLUE

public mixed COLOR_DARKBLUE = 'FF000080'

COLOR_DARKGREEN

public mixed COLOR_DARKGREEN = 'FF008000'

COLOR_DARKRED

public mixed COLOR_DARKRED = 'FF800000'

COLOR_DARKYELLOW

public mixed COLOR_DARKYELLOW = 'FF808000'

COLOR_GREEN

public mixed COLOR_GREEN = 'FF00FF00'

COLOR_MAGENTA

public mixed COLOR_MAGENTA = 'FFFF00FF'

COLOR_RED

public mixed COLOR_RED = 'FFFF0000'

COLOR_WHITE

public mixed COLOR_WHITE = 'FFFFFFFF'

COLOR_YELLOW

public mixed COLOR_YELLOW = 'FFFFFF00'

NAMED_COLOR_TRANSLATIONS

public mixed NAMED_COLOR_TRANSLATIONS = ['Black' => self::COLOR_BLACK, 'White' => self::COLOR_WHITE, 'Red' => self::COLOR_RED, 'Green' => self::COLOR_GREEN, 'Blue' => self::COLOR_BLUE, 'Yellow' => self::COLOR_YELLOW, 'Magenta' => self::COLOR_MAGENTA, 'Cyan' => self::COLOR_CYAN]

NAMED_COLORS

public mixed NAMED_COLORS = ['Black', 'White', 'Red', 'Green', 'Blue', 'Yellow', 'Magenta', 'Cyan']

VALIDATE_ARGB_SIZE

public mixed VALIDATE_ARGB_SIZE = 8

VALIDATE_COLOR_6

public mixed VALIDATE_COLOR_6 = '/^[A-F0-9]{6}$/i'

VALIDATE_COLOR_8

public mixed VALIDATE_COLOR_8 = '/^[A-F0-9]{8}$/i'

VALIDATE_RGB_SIZE

public mixed VALIDATE_RGB_SIZE = 6

Properties

$argb

ARGB - Alpha RGB.

protected string|null $argb = null

$isSupervisor

Supervisor?

protected bool $isSupervisor

$parentPropertyName

Parent property name.

protected string|null $parentPropertyName = null

Methods

__clone()

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

public __clone() : mixed

__construct()

Create a new Color.

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

ARGB value for the colour, or named colour

$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{rgb?: string, argb?: string, theme?: int} $styleArray) : $this
$spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray(['rgb' => '808080']);
Parameters
$styleArray : array{rgb?: string, argb?: string, theme?: int}

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

changeBrightness()

Adjust the brightness of a color.

public static changeBrightness(string $hexColourValue, float $adjustPercentage) : string
Parameters
$hexColourValue : string

The colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)

$adjustPercentage : float

The percentage by which to adjust the colour as a float from -1 to 1

Return values
string

The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)

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'

getARGB()

Get ARGB.

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

getBlue()

Get the blue colour component of an RGB value.

public static getBlue(string $rgbValue[, bool $hex = true ]) : int|string
Parameters
$rgbValue : string

The colour as an RGB value (e.g. FF00CCCC or CCDDEE

$hex : bool = true

Flag indicating whether the component should be returned as a hex or a decimal value

Return values
int|string

The blue colour component

getGreen()

Get the green colour component of an RGB value.

public static getGreen(string $rgbValue[, bool $hex = true ]) : int|string
Parameters
$rgbValue : string

The colour as an RGB value (e.g. FF00CCCC or CCDDEE

$hex : bool = true

Flag indicating whether the component should be returned as a hex or a decimal value

Return values
int|string

The green colour component

getHasChanged()

public getHasChanged() : bool
Return values
bool

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

getRed()

Get the red colour component of an RGB value.

public static getRed(string $rgbValue[, bool $hex = true ]) : int|string
Parameters
$rgbValue : string

The colour as an RGB value (e.g. FF00CCCC or CCDDEE

$hex : bool = true

Flag indicating whether the component should be returned as a hex or a decimal value

Return values
int|string

The red colour component

getRGB()

Get RGB.

public getRGB() : 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

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>

getTheme()

public getTheme() : int
Return values
int

indexedColor()

Get indexed color.

public static indexedColor(int $colorIndex[, bool $background = false ][, null|array<string|int, string> $palette = null ]) : self
Parameters
$colorIndex : int

Index entry point into the colour array

$background : bool = false

Flag to indicate whether default background or foreground colour should be returned if the indexed colour doesn't exist

$palette : null|array<string|int, string> = null
Return values
self

setARGB()

Set ARGB.

public setARGB([string|null $colorValue = self::COLOR_BLACK ][, bool $nullStringOkay = false ]) : $this
Parameters
$colorValue : string|null = self::COLOR_BLACK

ARGB value, or a named color

$nullStringOkay : bool = false
Return values
$this

setHyperlinkTheme()

public setHyperlinkTheme() : self
Return values
self

setRGB()

Set RGB.

public setRGB([string|null $colorValue = self::COLOR_BLACK ]) : $this
Parameters
$colorValue : string|null = self::COLOR_BLACK

RGB value, or a named color

Return values
$this

setTheme()

public setTheme(int $theme) : self
Parameters
$theme : int
Return values
self

exportArray1()

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

protected exportArray1() : array<string|int, mixed>
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

        
On this page

Search results