class Color extends Supervisor (View source)

Constants

COLOR_BLACK

COLOR_WHITE

COLOR_RED

COLOR_DARKRED

COLOR_BLUE

COLOR_DARKBLUE

COLOR_GREEN

COLOR_DARKGREEN

COLOR_YELLOW

COLOR_DARKYELLOW

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
static protected array $indexedColors Indexed colors array.
protected string $argb ARGB - Alpha RGB.

Methods

__construct(string $pARGB = self::COLOR_BLACK, bool $isSupervisor = false, bool $isConditional = false)

Create a new Color.

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
getARGB()

Get ARGB.

setARGB(string $pValue)

Set ARGB.

string
getRGB()

Get RGB.

setRGB(string $pValue)

Set RGB.

static string
getRed(string $RGB, bool $hex = true)

Get the red colour component of an RGB value.

static string
getGreen(string $RGB, bool $hex = true)

Get the green colour component of an RGB value.

static string
getBlue(string $RGB, bool $hex = true)

Get the blue colour component of an RGB value.

static string
changeBrightness(string $hex, float $adjustPercentage)

Adjust the brightness of a color.

static Color
indexedColor(int $pIndex, bool $background = false)

Get indexed color.

string
getHashCode()

Get hash code.

Details

__construct(string $pARGB = self::COLOR_BLACK, bool $isSupervisor = false, bool $isConditional = false)

Create a new Color.

Parameters

string $pARGB ARGB value for the colour
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.

Color getSharedComponent()

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

Only used for style supervisor.

Return Value

Color

array getStyleArray(array $array)

Build style array from subcomponents.

Parameters

array $array

Return Value

array

Color applyFromArray(array $pStyles)

Apply styles from array.

$spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray(['rgb' => '808080']);

Parameters

array $pStyles Array containing style information

Return Value

Color

Exceptions

Exception

string getARGB()

Get ARGB.

Return Value

string

Color setARGB(string $pValue)

Set ARGB.

Parameters

string $pValue see self::COLOR_*

Return Value

Color

string getRGB()

Get RGB.

Return Value

string

Color setRGB(string $pValue)

Set RGB.

Parameters

string $pValue RGB value

Return Value

Color

static string getRed(string $RGB, bool $hex = true)

Get the red colour component of an RGB value.

Parameters

string $RGB The colour as an RGB value (e.g. FF00CCCC or CCDDEE
bool $hex Flag indicating whether the component should be returned as a hex or a decimal value

Return Value

string The red colour component

static string getGreen(string $RGB, bool $hex = true)

Get the green colour component of an RGB value.

Parameters

string $RGB The colour as an RGB value (e.g. FF00CCCC or CCDDEE
bool $hex Flag indicating whether the component should be returned as a hex or a decimal value

Return Value

string The green colour component

static string getBlue(string $RGB, bool $hex = true)

Get the blue colour component of an RGB value.

Parameters

string $RGB The colour as an RGB value (e.g. FF00CCCC or CCDDEE
bool $hex Flag indicating whether the component should be returned as a hex or a decimal value

Return Value

string The blue colour component

static string changeBrightness(string $hex, float $adjustPercentage)

Adjust the brightness of a color.

Parameters

string $hex The colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE)
float $adjustPercentage The percentage by which to adjust the colour as a float from -1 to 1

Return Value

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

static Color indexedColor(int $pIndex, bool $background = false)

Get indexed color.

Parameters

int $pIndex Index entry point into the colour array
bool $background Flag to indicate whether default background or foreground colour should be returned if the indexed colour doesn't exist

Return Value

Color

string getHashCode()

Get hash code.

Return Value

string Hash code