ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_Style_Color Class Reference
+ Inheritance diagram for PHPExcel_Style_Color:
+ Collaboration diagram for PHPExcel_Style_Color:

Public Member Functions

 __construct ($pARGB=PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor=FALSE, $isConditional=FALSE)
 Create a new PHPExcel_Style_Color. More...
 
 bindParent ($parent, $parentPropertyName=NULL)
 Bind parent. More...
 
 getSharedComponent ()
 Get the shared style component for the currently active cell in currently active sheet. More...
 
 getStyleArray ($array)
 Build style array from subcomponents. More...
 
 applyFromArray ($pStyles=NULL)
 Apply styles from array. More...
 
 getARGB ()
 Get ARGB. More...
 
 setARGB ($pValue=PHPExcel_Style_Color::COLOR_BLACK)
 Set ARGB. More...
 
 getRGB ()
 Get RGB. More...
 
 setRGB ($pValue='000000')
 Set RGB. More...
 
 getHashCode ()
 Get hash code. More...
 
- Public Member Functions inherited from PHPExcel_Style_Supervisor
 __construct ($isSupervisor=FALSE)
 Create a new PHPExcel_Style_Alignment. More...
 
 bindParent ($parent, $parentPropertyName=NULL)
 Bind parent. More...
 
 getIsSupervisor ()
 Is this a supervisor or a cell style component? More...
 
 getActiveSheet ()
 Get the currently active sheet. More...
 
 getSelectedCells ()
 Get the currently active cell coordinate in currently active sheet. More...
 
 getActiveCell ()
 Get the currently active cell coordinate in currently active sheet. More...
 
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy. More...
 
 getHashCode ()
 Get hash code. More...
 

Static Public Member Functions

static getRed ($RGB, $hex=TRUE)
 Get the red colour component of an RGB value. More...
 
static getGreen ($RGB, $hex=TRUE)
 Get the green colour component of an RGB value. More...
 
static getBlue ($RGB, $hex=TRUE)
 Get the blue colour component of an RGB value. More...
 
static changeBrightness ($hex, $adjustPercentage)
 Adjust the brightness of a color. More...
 
static indexedColor ($pIndex, $background=FALSE)
 Get indexed color. More...
 

Data Fields

const COLOR_BLACK = 'FF000000'
 
const COLOR_WHITE = 'FFFFFFFF'
 
const COLOR_RED = 'FFFF0000'
 
const COLOR_DARKRED = 'FF800000'
 
const COLOR_BLUE = 'FF0000FF'
 
const COLOR_DARKBLUE = 'FF000080'
 
const COLOR_GREEN = 'FF00FF00'
 
const COLOR_DARKGREEN = 'FF008000'
 
const COLOR_YELLOW = 'FFFFFF00'
 
const COLOR_DARKYELLOW = 'FF808000'
 

Protected Attributes

 $_argb = NULL
 
 $_parentPropertyName
 
- Protected Attributes inherited from PHPExcel_Style_Supervisor
 $_isSupervisor
 
 $_parent
 

Static Protected Attributes

static $_indexedColors
 

Static Private Member Functions

static _getColourComponent ($RGB, $offset, $hex=TRUE)
 Get a specified colour component of an RGB value. More...
 

Detailed Description

Definition at line 36 of file Color.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_Style_Color::__construct (   $pARGB = PHPExcel_Style_Color::COLOR_BLACK,
  $isSupervisor = FALSE,
  $isConditional = FALSE 
)

Create a new PHPExcel_Style_Color.

Parameters
string$pARGBARGB value for the colour
boolean$isSupervisorFlag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are
boolean$isConditionalFlag indicating if this is a conditional style or not Leave this value at default unless you understand exactly what its ramifications are

Definition at line 83 of file Color.php.

84 {
85 // Supervisor?
86 parent::__construct($isSupervisor);
87
88 // Initialise values
89 if (!$isConditional) {
90 $this->_argb = $pARGB;
91 }
92 }

Member Function Documentation

◆ _getColourComponent()

static PHPExcel_Style_Color::_getColourComponent (   $RGB,
  $offset,
  $hex = TRUE 
)
staticprivate

Get a specified colour component of an RGB value.

Parameters
string$RGBThe colour as an RGB value (e.g. FF00CCCC or CCDDEE
int$offsetPosition within the RGB value to extract
boolean$hexFlag indicating whether the component should be returned as a hex or a decimal value
Returns
string The extracted colour component

Definition at line 250 of file Color.php.

250 {
251 $colour = substr($RGB, $offset, 2);
252 if (!$hex)
253 $colour = hexdec($colour);
254 return $colour;
255 }

Referenced by getBlue(), getGreen(), and getRed().

+ Here is the caller graph for this function:

◆ applyFromArray()

PHPExcel_Style_Color::applyFromArray (   $pStyles = NULL)

Apply styles from array.

$objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray( array('rgb' => '808080') );

Parameters
array$pStylesArray containing style information
Exceptions
PHPExcel_Exception
Returns
PHPExcel_Style_Color

Definition at line 160 of file Color.php.

160 {
161 if (is_array($pStyles)) {
162 if ($this->_isSupervisor) {
163 $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
164 } else {
165 if (array_key_exists('rgb', $pStyles)) {
166 $this->setRGB($pStyles['rgb']);
167 }
168 if (array_key_exists('argb', $pStyles)) {
169 $this->setARGB($pStyles['argb']);
170 }
171 }
172 } else {
173 throw new PHPExcel_Exception("Invalid style array passed.");
174 }
175 return $this;
176 }
setARGB($pValue=PHPExcel_Style_Color::COLOR_BLACK)
Set ARGB.
Definition: Color.php:196
getStyleArray($array)
Build style array from subcomponents.
Definition: Color.php:132
setRGB($pValue='000000')
Set RGB.
Definition: Color.php:227
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:92
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:103

References PHPExcel_Style_Supervisor\getActiveSheet(), PHPExcel_Style_Supervisor\getSelectedCells(), getStyleArray(), setARGB(), and setRGB().

+ Here is the call graph for this function:

◆ bindParent()

PHPExcel_Style_Color::bindParent (   $parent,
  $parentPropertyName = NULL 
)

Bind parent.

Only used for supervisor

Parameters
mixed$parent
string$parentPropertyName
Returns
PHPExcel_Style_Color

Reimplemented from PHPExcel_Style_Supervisor.

Definition at line 101 of file Color.php.

102 {
103 $this->_parent = $parent;
104 $this->_parentPropertyName = $parentPropertyName;
105 return $this;
106 }

◆ changeBrightness()

static PHPExcel_Style_Color::changeBrightness (   $hex,
  $adjustPercentage 
)
static

Adjust the brightness of a color.

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

Definition at line 300 of file Color.php.

300 {
301 $rgba = (strlen($hex) == 8);
302
303 $red = self::getRed($hex, FALSE);
304 $green = self::getGreen($hex, FALSE);
305 $blue = self::getBlue($hex, FALSE);
306 if ($adjustPercentage > 0) {
307 $red += (255 - $red) * $adjustPercentage;
308 $green += (255 - $green) * $adjustPercentage;
309 $blue += (255 - $blue) * $adjustPercentage;
310 } else {
311 $red += $red * $adjustPercentage;
312 $green += $green * $adjustPercentage;
313 $blue += $blue * $adjustPercentage;
314 }
315
316 if ($red < 0) $red = 0;
317 elseif ($red > 255) $red = 255;
318 if ($green < 0) $green = 0;
319 elseif ($green > 255) $green = 255;
320 if ($blue < 0) $blue = 0;
321 elseif ($blue > 255) $blue = 255;
322
323 $rgb = strtoupper( str_pad(dechex($red), 2, '0', 0) .
324 str_pad(dechex($green), 2, '0', 0) .
325 str_pad(dechex($blue), 2, '0', 0)
326 );
327 return (($rgba) ? 'FF' : '') . $rgb;
328 }
PHPExcel root directory.
Definition: PHPExcel.php:30
static getRed($RGB, $hex=TRUE)
Get the red colour component of an RGB value.
Definition: Color.php:265
static getBlue($RGB, $hex=TRUE)
Get the blue colour component of an RGB value.
Definition: Color.php:289
static getGreen($RGB, $hex=TRUE)
Get the green colour component of an RGB value.
Definition: Color.php:277
$red
Definition: example_030.php:80
$green
Definition: example_030.php:83
$blue
Definition: example_030.php:81

References $blue, $green, $red, getBlue(), getGreen(), and getRed().

Referenced by PHPExcel_Reader_Excel2007\_readColor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getARGB()

PHPExcel_Style_Color::getARGB ( )

Get ARGB.

Returns
string

Definition at line 183 of file Color.php.

183 {
184 if ($this->_isSupervisor) {
185 return $this->getSharedComponent()->getARGB();
186 }
187 return $this->_argb;
188 }
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Color.php:114

References $_argb, and getSharedComponent().

+ Here is the call graph for this function:

◆ getBlue()

static PHPExcel_Style_Color::getBlue (   $RGB,
  $hex = TRUE 
)
static

Get the blue colour component of an RGB value.

Parameters
string$RGBThe colour as an RGB value (e.g. FF00CCCC or CCDDEE
boolean$hexFlag indicating whether the component should be returned as a hex or a decimal value
Returns
string The blue colour component

Definition at line 289 of file Color.php.

289 {
290 return self::_getColourComponent($RGB, strlen($RGB) - 2, $hex);
291 }
static _getColourComponent($RGB, $offset, $hex=TRUE)
Get a specified colour component of an RGB value.
Definition: Color.php:250

References _getColourComponent().

Referenced by changeBrightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGreen()

static PHPExcel_Style_Color::getGreen (   $RGB,
  $hex = TRUE 
)
static

Get the green colour component of an RGB value.

Parameters
string$RGBThe colour as an RGB value (e.g. FF00CCCC or CCDDEE
boolean$hexFlag indicating whether the component should be returned as a hex or a decimal value
Returns
string The green colour component

Definition at line 277 of file Color.php.

277 {
278 return self::_getColourComponent($RGB, strlen($RGB) - 4, $hex);
279 }

References _getColourComponent().

Referenced by changeBrightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHashCode()

PHPExcel_Style_Color::getHashCode ( )

Get hash code.

Returns
string Hash code

Implements PHPExcel_IComparable.

Definition at line 419 of file Color.php.

419 {
420 if ($this->_isSupervisor) {
421 return $this->getSharedComponent()->getHashCode();
422 }
423 return md5(
424 $this->_argb
425 . __CLASS__
426 );
427 }

References getSharedComponent().

+ Here is the call graph for this function:

◆ getRed()

static PHPExcel_Style_Color::getRed (   $RGB,
  $hex = TRUE 
)
static

Get the red colour component of an RGB value.

Parameters
string$RGBThe colour as an RGB value (e.g. FF00CCCC or CCDDEE
boolean$hexFlag indicating whether the component should be returned as a hex or a decimal value
Returns
string The red colour component

Definition at line 265 of file Color.php.

265 {
266 return self::_getColourComponent($RGB, strlen($RGB) - 6, $hex);
267 }

References _getColourComponent().

Referenced by changeBrightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRGB()

PHPExcel_Style_Color::getRGB ( )

Get RGB.

Returns
string

Definition at line 214 of file Color.php.

214 {
215 if ($this->_isSupervisor) {
216 return $this->getSharedComponent()->getRGB();
217 }
218 return substr($this->_argb, 2);
219 }

References getSharedComponent().

+ Here is the call graph for this function:

◆ getSharedComponent()

PHPExcel_Style_Color::getSharedComponent ( )

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

Only used for style supervisor

Returns
PHPExcel_Style_Color

Definition at line 114 of file Color.php.

115 {
116 switch ($this->_parentPropertyName) {
117 case '_endColor':
118 return $this->_parent->getSharedComponent()->getEndColor(); break;
119 case '_color':
120 return $this->_parent->getSharedComponent()->getColor(); break;
121 case '_startColor':
122 return $this->_parent->getSharedComponent()->getStartColor(); break;
123 }
124 }

Referenced by getARGB(), getHashCode(), and getRGB().

+ Here is the caller graph for this function:

◆ getStyleArray()

PHPExcel_Style_Color::getStyleArray (   $array)

Build style array from subcomponents.

Parameters
array$array
Returns
array

Definition at line 132 of file Color.php.

133 {
134 switch ($this->_parentPropertyName) {
135 case '_endColor':
136 $key = 'endcolor';
137 break;
138 case '_color':
139 $key = 'color';
140 break;
141 case '_startColor':
142 $key = 'startcolor';
143 break;
144
145 }
146 return $this->_parent->getStyleArray(array($key => $array));
147 }

Referenced by applyFromArray(), setARGB(), and setRGB().

+ Here is the caller graph for this function:

◆ indexedColor()

static PHPExcel_Style_Color::indexedColor (   $pIndex,
  $background = FALSE 
)
static

Get indexed color.

Parameters
int$pIndexIndex entry point into the colour array
boolean$backgroundFlag to indicate whether default background or foreground colour should be returned if the indexed colour doesn't exist
Returns
PHPExcel_Style_Color

Definition at line 338 of file Color.php.

338 {
339 // Clean parameter
340 $pIndex = intval($pIndex);
341
342 // Indexed colors
343 if (is_null(self::$_indexedColors)) {
344 self::$_indexedColors = array(
345 1 => 'FF000000', // System Colour #1 - Black
346 2 => 'FFFFFFFF', // System Colour #2 - White
347 3 => 'FFFF0000', // System Colour #3 - Red
348 4 => 'FF00FF00', // System Colour #4 - Green
349 5 => 'FF0000FF', // System Colour #5 - Blue
350 6 => 'FFFFFF00', // System Colour #6 - Yellow
351 7 => 'FFFF00FF', // System Colour #7- Magenta
352 8 => 'FF00FFFF', // System Colour #8- Cyan
353 9 => 'FF800000', // Standard Colour #9
354 10 => 'FF008000', // Standard Colour #10
355 11 => 'FF000080', // Standard Colour #11
356 12 => 'FF808000', // Standard Colour #12
357 13 => 'FF800080', // Standard Colour #13
358 14 => 'FF008080', // Standard Colour #14
359 15 => 'FFC0C0C0', // Standard Colour #15
360 16 => 'FF808080', // Standard Colour #16
361 17 => 'FF9999FF', // Chart Fill Colour #17
362 18 => 'FF993366', // Chart Fill Colour #18
363 19 => 'FFFFFFCC', // Chart Fill Colour #19
364 20 => 'FFCCFFFF', // Chart Fill Colour #20
365 21 => 'FF660066', // Chart Fill Colour #21
366 22 => 'FFFF8080', // Chart Fill Colour #22
367 23 => 'FF0066CC', // Chart Fill Colour #23
368 24 => 'FFCCCCFF', // Chart Fill Colour #24
369 25 => 'FF000080', // Chart Line Colour #25
370 26 => 'FFFF00FF', // Chart Line Colour #26
371 27 => 'FFFFFF00', // Chart Line Colour #27
372 28 => 'FF00FFFF', // Chart Line Colour #28
373 29 => 'FF800080', // Chart Line Colour #29
374 30 => 'FF800000', // Chart Line Colour #30
375 31 => 'FF008080', // Chart Line Colour #31
376 32 => 'FF0000FF', // Chart Line Colour #32
377 33 => 'FF00CCFF', // Standard Colour #33
378 34 => 'FFCCFFFF', // Standard Colour #34
379 35 => 'FFCCFFCC', // Standard Colour #35
380 36 => 'FFFFFF99', // Standard Colour #36
381 37 => 'FF99CCFF', // Standard Colour #37
382 38 => 'FFFF99CC', // Standard Colour #38
383 39 => 'FFCC99FF', // Standard Colour #39
384 40 => 'FFFFCC99', // Standard Colour #40
385 41 => 'FF3366FF', // Standard Colour #41
386 42 => 'FF33CCCC', // Standard Colour #42
387 43 => 'FF99CC00', // Standard Colour #43
388 44 => 'FFFFCC00', // Standard Colour #44
389 45 => 'FFFF9900', // Standard Colour #45
390 46 => 'FFFF6600', // Standard Colour #46
391 47 => 'FF666699', // Standard Colour #47
392 48 => 'FF969696', // Standard Colour #48
393 49 => 'FF003366', // Standard Colour #49
394 50 => 'FF339966', // Standard Colour #50
395 51 => 'FF003300', // Standard Colour #51
396 52 => 'FF333300', // Standard Colour #52
397 53 => 'FF993300', // Standard Colour #53
398 54 => 'FF993366', // Standard Colour #54
399 55 => 'FF333399', // Standard Colour #55
400 56 => 'FF333333' // Standard Colour #56
401 );
402 }
403
404 if (array_key_exists($pIndex, self::$_indexedColors)) {
405 return new PHPExcel_Style_Color(self::$_indexedColors[$pIndex]);
406 }
407
408 if ($background) {
409 return new PHPExcel_Style_Color('FFFFFFFF');
410 }
411 return new PHPExcel_Style_Color('FF000000');
412 }

Referenced by PHPExcel_Reader_Excel2007\_readColor(), and PHPExcel_Reader_Excel2007_Chart\_readColor().

+ Here is the caller graph for this function:

◆ setARGB()

PHPExcel_Style_Color::setARGB (   $pValue = PHPExcel_Style_Color::COLOR_BLACK)

Set ARGB.

Parameters
string$pValue
Returns
PHPExcel_Style_Color

Definition at line 196 of file Color.php.

196 {
197 if ($pValue == '') {
199 }
200 if ($this->_isSupervisor) {
201 $styleArray = $this->getStyleArray(array('argb' => $pValue));
202 $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
203 } else {
204 $this->_argb = $pValue;
205 }
206 return $this;
207 }

References COLOR_BLACK, PHPExcel_Style_Supervisor\getActiveSheet(), PHPExcel_Style_Supervisor\getSelectedCells(), and getStyleArray().

Referenced by applyFromArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRGB()

PHPExcel_Style_Color::setRGB (   $pValue = '000000')

Set RGB.

Parameters
string$pValueRGB value
Returns
PHPExcel_Style_Color

Definition at line 227 of file Color.php.

227 {
228 if ($pValue == '') {
229 $pValue = '000000';
230 }
231 if ($this->_isSupervisor) {
232 $styleArray = $this->getStyleArray(array('argb' => 'FF' . $pValue));
233 $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
234 } else {
235 $this->_argb = 'FF' . $pValue;
236 }
237 return $this;
238 }

References PHPExcel_Style_Supervisor\getActiveSheet(), PHPExcel_Style_Supervisor\getSelectedCells(), and getStyleArray().

Referenced by applyFromArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $_argb

PHPExcel_Style_Color::$_argb = NULL
protected

Definition at line 62 of file Color.php.

Referenced by getARGB().

◆ $_indexedColors

PHPExcel_Style_Color::$_indexedColors
staticprotected

Definition at line 55 of file Color.php.

◆ $_parentPropertyName

PHPExcel_Style_Color::$_parentPropertyName
protected

Definition at line 69 of file Color.php.

◆ COLOR_BLACK

◆ COLOR_BLUE

const PHPExcel_Style_Color::COLOR_BLUE = 'FF0000FF'

Definition at line 43 of file Color.php.

◆ COLOR_DARKBLUE

const PHPExcel_Style_Color::COLOR_DARKBLUE = 'FF000080'

Definition at line 44 of file Color.php.

◆ COLOR_DARKGREEN

const PHPExcel_Style_Color::COLOR_DARKGREEN = 'FF008000'

Definition at line 46 of file Color.php.

◆ COLOR_DARKRED

const PHPExcel_Style_Color::COLOR_DARKRED = 'FF800000'

Definition at line 42 of file Color.php.

◆ COLOR_DARKYELLOW

const PHPExcel_Style_Color::COLOR_DARKYELLOW = 'FF808000'

Definition at line 48 of file Color.php.

◆ COLOR_GREEN

const PHPExcel_Style_Color::COLOR_GREEN = 'FF00FF00'

Definition at line 45 of file Color.php.

◆ COLOR_RED

const PHPExcel_Style_Color::COLOR_RED = 'FFFF0000'

Definition at line 41 of file Color.php.

◆ COLOR_WHITE

const PHPExcel_Style_Color::COLOR_WHITE = 'FFFFFFFF'

Definition at line 40 of file Color.php.

Referenced by PHPExcel_Style_Fill\__construct().

◆ COLOR_YELLOW

const PHPExcel_Style_Color::COLOR_YELLOW = 'FFFFFF00'

Definition at line 47 of file Color.php.


The documentation for this class was generated from the following file: