ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Style\Fill Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Style\Fill:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Style\Fill:

Public Member Functions

 __construct ($isSupervisor=false, $isConditional=false)
 Create a new Fill. 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 (array $pStyles)
 Apply styles from array. More...
 
 getFillType ()
 Get Fill Type. More...
 
 setFillType ($pValue)
 Set Fill Type. More...
 
 getRotation ()
 Get Rotation. More...
 
 setRotation ($pValue)
 Set Rotation. More...
 
 getStartColor ()
 Get Start Color. More...
 
 setStartColor (Color $pValue)
 Set Start Color. More...
 
 getEndColor ()
 Get End Color. More...
 
 setEndColor (Color $pValue)
 Set End Color. More...
 
 getHashCode ()
 Get hash code. More...
 
- Public Member Functions inherited from PhpOffice\PhpSpreadsheet\Style\Supervisor
 __construct ($isSupervisor=false)
 Create a new Supervisor. 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...
 
 exportArray ()
 Export style as array. More...
 

Data Fields

const FILL_NONE = 'none'
 
const FILL_SOLID = 'solid'
 
const FILL_GRADIENT_LINEAR = 'linear'
 
const FILL_GRADIENT_PATH = 'path'
 
const FILL_PATTERN_DARKDOWN = 'darkDown'
 
const FILL_PATTERN_DARKGRAY = 'darkGray'
 
const FILL_PATTERN_DARKGRID = 'darkGrid'
 
const FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal'
 
const FILL_PATTERN_DARKTRELLIS = 'darkTrellis'
 
const FILL_PATTERN_DARKUP = 'darkUp'
 
const FILL_PATTERN_DARKVERTICAL = 'darkVertical'
 
const FILL_PATTERN_GRAY0625 = 'gray0625'
 
const FILL_PATTERN_GRAY125 = 'gray125'
 
const FILL_PATTERN_LIGHTDOWN = 'lightDown'
 
const FILL_PATTERN_LIGHTGRAY = 'lightGray'
 
const FILL_PATTERN_LIGHTGRID = 'lightGrid'
 
const FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal'
 
const FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis'
 
const FILL_PATTERN_LIGHTUP = 'lightUp'
 
const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical'
 
const FILL_PATTERN_MEDIUMGRAY = 'mediumGray'
 
 $startcolorIndex
 
 $endcolorIndex
 

Protected Member Functions

 exportArray1 ()
 
- Protected Member Functions inherited from PhpOffice\PhpSpreadsheet\Style\Supervisor
 exportArray1 ()
 Abstract method to be implemented in anything which extends this class. More...
 
 exportArray2 (array &$exportedArray, string $index, $objOrValue)
 Populate array from exportArray1. More...
 

Protected Attributes

 $fillType = self::FILL_NONE
 
 $rotation = 0
 
 $startColor
 
 $endColor
 
- Protected Attributes inherited from PhpOffice\PhpSpreadsheet\Style\Supervisor
 $isSupervisor
 
 $parent
 
 $parentPropertyName
 

Detailed Description

Definition at line 5 of file Fill.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Style\Fill::__construct (   $isSupervisor = false,
  $isConditional = false 
)

Create a new Fill.

Parameters
bool$isSupervisorFlag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are
bool$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 78 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\$isSupervisor, PhpOffice\PhpSpreadsheet\Style\Color\COLOR_BLACK, and PhpOffice\PhpSpreadsheet\Style\Color\COLOR_WHITE.

79  {
80  // Supervisor?
81  parent::__construct($isSupervisor);
82 
83  // Initialise values
84  if ($isConditional) {
85  $this->fillType = null;
86  }
87  $this->startColor = new Color(Color::COLOR_WHITE, $isSupervisor, $isConditional);
88  $this->endColor = new Color(Color::COLOR_BLACK, $isSupervisor, $isConditional);
89 
90  // bind parent if we are a supervisor
91  if ($isSupervisor) {
92  $this->startColor->bindParent($this, 'startColor');
93  $this->endColor->bindParent($this, 'endColor');
94  }
95  }

Member Function Documentation

◆ applyFromArray()

PhpOffice\PhpSpreadsheet\Style\Fill::applyFromArray ( array  $pStyles)

Apply styles from array.

$spreadsheet->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray( [ 'fillType' => Fill::FILL_GRADIENT_LINEAR, 'rotation' => 0, 'startColor' => [ 'rgb' => '000000' ], 'endColor' => [ 'argb' => 'FFFFFFFF' ] ] );

Parameters
array$pStylesArray containing style information
Returns
$this

Definition at line 142 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Fill\getEndColor(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), PhpOffice\PhpSpreadsheet\Style\Fill\getStartColor(), PhpOffice\PhpSpreadsheet\Style\Fill\getStyleArray(), PhpOffice\PhpSpreadsheet\Style\Fill\setFillType(), and PhpOffice\PhpSpreadsheet\Style\Fill\setRotation().

143  {
144  if ($this->isSupervisor) {
145  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
146  } else {
147  if (isset($pStyles['fillType'])) {
148  $this->setFillType($pStyles['fillType']);
149  }
150  if (isset($pStyles['rotation'])) {
151  $this->setRotation($pStyles['rotation']);
152  }
153  if (isset($pStyles['startColor'])) {
154  $this->getStartColor()->applyFromArray($pStyles['startColor']);
155  }
156  if (isset($pStyles['endColor'])) {
157  $this->getEndColor()->applyFromArray($pStyles['endColor']);
158  }
159  if (isset($pStyles['color'])) {
160  $this->getStartColor()->applyFromArray($pStyles['color']);
161  $this->getEndColor()->applyFromArray($pStyles['color']);
162  }
163  }
164 
165  return $this;
166  }
setFillType($pValue)
Set Fill Type.
Definition: Fill.php:189
setRotation($pValue)
Set Rotation.
Definition: Fill.php:222
getStartColor()
Get Start Color.
Definition: Fill.php:239
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getStyleArray($array)
Build style array from subcomponents.
Definition: Fill.php:115
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
getEndColor()
Get End Color.
Definition: Fill.php:269
+ Here is the call graph for this function:

◆ exportArray1()

PhpOffice\PhpSpreadsheet\Style\Fill::exportArray1 ( )
protected

Definition at line 315 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\exportArray2(), PhpOffice\PhpSpreadsheet\Style\Fill\getEndColor(), PhpOffice\PhpSpreadsheet\Style\Fill\getFillType(), PhpOffice\PhpSpreadsheet\Style\Fill\getRotation(), and PhpOffice\PhpSpreadsheet\Style\Fill\getStartColor().

315  : array
316  {
317  $exportedArray = [];
318  $this->exportArray2($exportedArray, 'endColor', $this->getEndColor());
319  $this->exportArray2($exportedArray, 'fillType', $this->getFillType());
320  $this->exportArray2($exportedArray, 'rotation', $this->getRotation());
321  $this->exportArray2($exportedArray, 'startColor', $this->getStartColor());
322 
323  return $exportedArray;
324  }
getStartColor()
Get Start Color.
Definition: Fill.php:239
getFillType()
Get Fill Type.
Definition: Fill.php:173
getEndColor()
Get End Color.
Definition: Fill.php:269
exportArray2(array &$exportedArray, string $index, $objOrValue)
Populate array from exportArray1.
Definition: Supervisor.php:150
+ Here is the call graph for this function:

◆ getEndColor()

◆ getFillType()

PhpOffice\PhpSpreadsheet\Style\Fill::getFillType ( )

◆ getHashCode()

PhpOffice\PhpSpreadsheet\Style\Fill::getHashCode ( )

Get hash code.

Returns
string Hash code

Implements PhpOffice\PhpSpreadsheet\IComparable.

Definition at line 299 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Fill\getEndColor(), PhpOffice\PhpSpreadsheet\Style\Fill\getFillType(), PhpOffice\PhpSpreadsheet\Style\Fill\getRotation(), PhpOffice\PhpSpreadsheet\Style\Fill\getSharedComponent(), and PhpOffice\PhpSpreadsheet\Style\Fill\getStartColor().

300  {
301  if ($this->isSupervisor) {
302  return $this->getSharedComponent()->getHashCode();
303  }
304  // Note that we don't care about colours for fill type NONE, but could have duplicate NONEs with
305  // different hashes if we don't explicitly prevent this
306  return md5(
307  $this->getFillType() .
308  $this->getRotation() .
309  ($this->getFillType() !== self::FILL_NONE ? $this->getStartColor()->getHashCode() : '') .
310  ($this->getFillType() !== self::FILL_NONE ? $this->getEndColor()->getHashCode() : '') .
311  __CLASS__
312  );
313  }
getStartColor()
Get Start Color.
Definition: Fill.php:239
getFillType()
Get Fill Type.
Definition: Fill.php:173
getHashCode()
Get hash code.
Definition: Fill.php:299
getEndColor()
Get End Color.
Definition: Fill.php:269
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Fill.php:103
+ Here is the call graph for this function:

◆ getRotation()

PhpOffice\PhpSpreadsheet\Style\Fill::getRotation ( )

Get Rotation.

Returns
float

Definition at line 206 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Fill\$rotation, and PhpOffice\PhpSpreadsheet\Style\Fill\getSharedComponent().

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\exportArray1(), PhpOffice\PhpSpreadsheet\Style\Fill\getHashCode(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeGradientFill().

207  {
208  if ($this->isSupervisor) {
209  return $this->getSharedComponent()->getRotation();
210  }
211 
212  return $this->rotation;
213  }
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Fill.php:103
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSharedComponent()

PhpOffice\PhpSpreadsheet\Style\Fill::getSharedComponent ( )

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

Only used for style supervisor.

Returns
Fill

Definition at line 103 of file Fill.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\getFillType(), PhpOffice\PhpSpreadsheet\Style\Fill\getHashCode(), and PhpOffice\PhpSpreadsheet\Style\Fill\getRotation().

104  {
105  return $this->parent->getSharedComponent()->getFill();
106  }
+ Here is the caller graph for this function:

◆ getStartColor()

◆ getStyleArray()

PhpOffice\PhpSpreadsheet\Style\Fill::getStyleArray (   $array)

Build style array from subcomponents.

Parameters
array$array
Returns
array

Definition at line 115 of file Fill.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\applyFromArray(), PhpOffice\PhpSpreadsheet\Style\Fill\setFillType(), and PhpOffice\PhpSpreadsheet\Style\Fill\setRotation().

116  {
117  return ['fill' => $array];
118  }
+ Here is the caller graph for this function:

◆ setEndColor()

PhpOffice\PhpSpreadsheet\Style\Fill::setEndColor ( Color  $pValue)

Set End Color.

Returns
$this

Definition at line 279 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Fill\getEndColor(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getIsSupervisor(), and PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells().

280  {
281  // make sure parameter is a real color and not a supervisor
282  $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
283 
284  if ($this->isSupervisor) {
285  $styleArray = $this->getEndColor()->getStyleArray(['argb' => $color->getARGB()]);
286  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
287  } else {
288  $this->endColor = $color;
289  }
290 
291  return $this;
292  }
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
getEndColor()
Get End Color.
Definition: Fill.php:269
+ Here is the call graph for this function:

◆ setFillType()

PhpOffice\PhpSpreadsheet\Style\Fill::setFillType (   $pValue)

Set Fill Type.

Parameters
string$pValueFill type, see self::FILL_*
Returns
$this

Definition at line 189 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), and PhpOffice\PhpSpreadsheet\Style\Fill\getStyleArray().

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\applyFromArray(), and PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readNumberFormat().

190  {
191  if ($this->isSupervisor) {
192  $styleArray = $this->getStyleArray(['fillType' => $pValue]);
193  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
194  } else {
195  $this->fillType = $pValue;
196  }
197 
198  return $this;
199  }
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getStyleArray($array)
Build style array from subcomponents.
Definition: Fill.php:115
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRotation()

PhpOffice\PhpSpreadsheet\Style\Fill::setRotation (   $pValue)

Set Rotation.

Parameters
float$pValue
Returns
$this

Definition at line 222 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), and PhpOffice\PhpSpreadsheet\Style\Fill\getStyleArray().

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\applyFromArray(), and PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readNumberFormat().

223  {
224  if ($this->isSupervisor) {
225  $styleArray = $this->getStyleArray(['rotation' => $pValue]);
226  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
227  } else {
228  $this->rotation = $pValue;
229  }
230 
231  return $this;
232  }
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getStyleArray($array)
Build style array from subcomponents.
Definition: Fill.php:115
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStartColor()

PhpOffice\PhpSpreadsheet\Style\Fill::setStartColor ( Color  $pValue)

Set Start Color.

Returns
$this

Definition at line 249 of file Fill.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getIsSupervisor(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), and PhpOffice\PhpSpreadsheet\Style\Fill\getStartColor().

250  {
251  // make sure parameter is a real color and not a supervisor
252  $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
253 
254  if ($this->isSupervisor) {
255  $styleArray = $this->getStartColor()->getStyleArray(['argb' => $color->getARGB()]);
256  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
257  } else {
258  $this->startColor = $color;
259  }
260 
261  return $this;
262  }
getStartColor()
Get Start Color.
Definition: Fill.php:239
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
+ Here is the call graph for this function:

Field Documentation

◆ $endColor

PhpOffice\PhpSpreadsheet\Style\Fill::$endColor
protected

Definition at line 66 of file Fill.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\getEndColor().

◆ $endcolorIndex

PhpOffice\PhpSpreadsheet\Style\Fill::$endcolorIndex

Definition at line 38 of file Fill.php.

◆ $fillType

PhpOffice\PhpSpreadsheet\Style\Fill::$fillType = self::FILL_NONE
protected

Definition at line 45 of file Fill.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\getFillType().

◆ $rotation

PhpOffice\PhpSpreadsheet\Style\Fill::$rotation = 0
protected

Definition at line 52 of file Fill.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\getRotation().

◆ $startColor

PhpOffice\PhpSpreadsheet\Style\Fill::$startColor
protected

Definition at line 59 of file Fill.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Fill\getStartColor().

◆ $startcolorIndex

PhpOffice\PhpSpreadsheet\Style\Fill::$startcolorIndex

Definition at line 33 of file Fill.php.

◆ FILL_GRADIENT_LINEAR

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR = 'linear'

◆ FILL_GRADIENT_PATH

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH = 'path'

◆ FILL_NONE

◆ FILL_PATTERN_DARKDOWN

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKDOWN = 'darkDown'

Definition at line 12 of file Fill.php.

◆ FILL_PATTERN_DARKGRAY

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRAY = 'darkGray'

Definition at line 13 of file Fill.php.

◆ FILL_PATTERN_DARKGRID

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKGRID = 'darkGrid'

Definition at line 14 of file Fill.php.

◆ FILL_PATTERN_DARKHORIZONTAL

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal'

Definition at line 15 of file Fill.php.

◆ FILL_PATTERN_DARKTRELLIS

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKTRELLIS = 'darkTrellis'

Definition at line 16 of file Fill.php.

◆ FILL_PATTERN_DARKUP

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKUP = 'darkUp'

Definition at line 17 of file Fill.php.

◆ FILL_PATTERN_DARKVERTICAL

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_DARKVERTICAL = 'darkVertical'

Definition at line 18 of file Fill.php.

◆ FILL_PATTERN_GRAY0625

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625 = 'gray0625'

Definition at line 19 of file Fill.php.

◆ FILL_PATTERN_GRAY125

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125 = 'gray125'

◆ FILL_PATTERN_LIGHTDOWN

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTDOWN = 'lightDown'

Definition at line 21 of file Fill.php.

◆ FILL_PATTERN_LIGHTGRAY

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRAY = 'lightGray'

Definition at line 22 of file Fill.php.

◆ FILL_PATTERN_LIGHTGRID

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTGRID = 'lightGrid'

Definition at line 23 of file Fill.php.

◆ FILL_PATTERN_LIGHTHORIZONTAL

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal'

Definition at line 24 of file Fill.php.

◆ FILL_PATTERN_LIGHTTRELLIS

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis'

Definition at line 25 of file Fill.php.

◆ FILL_PATTERN_LIGHTUP

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTUP = 'lightUp'

Definition at line 26 of file Fill.php.

◆ FILL_PATTERN_LIGHTVERTICAL

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTVERTICAL = 'lightVertical'

Definition at line 27 of file Fill.php.

◆ FILL_PATTERN_MEDIUMGRAY

const PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_MEDIUMGRAY = 'mediumGray'

Definition at line 28 of file Fill.php.

◆ FILL_SOLID


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