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

Public Member Functions

 __construct ($isSupervisor=false)
 Create a new Borders. 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...
 
 getLeft ()
 Get Left. More...
 
 getRight ()
 Get Right. More...
 
 getTop ()
 Get Top. More...
 
 getBottom ()
 Get Bottom. More...
 
 getDiagonal ()
 Get Diagonal. More...
 
 getAllBorders ()
 Get AllBorders (pseudo-border). More...
 
 getOutline ()
 Get Outline (pseudo-border). More...
 
 getInside ()
 Get Inside (pseudo-border). More...
 
 getVertical ()
 Get Vertical (pseudo-border). More...
 
 getHorizontal ()
 Get Horizontal (pseudo-border). More...
 
 getDiagonalDirection ()
 Get DiagonalDirection. More...
 
 setDiagonalDirection ($pValue)
 Set DiagonalDirection. 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 DIAGONAL_NONE = 0
 
const DIAGONAL_UP = 1
 
const DIAGONAL_DOWN = 2
 
const DIAGONAL_BOTH = 3
 

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

 $left
 
 $right
 
 $top
 
 $bottom
 
 $diagonal
 
 $diagonalDirection
 
 $allBorders
 
 $outline
 
 $inside
 
 $vertical
 
 $horizontal
 
- Protected Attributes inherited from PhpOffice\PhpSpreadsheet\Style\Supervisor
 $isSupervisor
 
 $parent
 
 $parentPropertyName
 

Detailed Description

Definition at line 7 of file Borders.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Style\Borders::__construct (   $isSupervisor = false)

Create a new Borders.

Parameters
bool$isSupervisorFlag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are

Definition at line 99 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\$isSupervisor, and left.

100  {
101  // Supervisor?
102  parent::__construct($isSupervisor);
103 
104  // Initialise values
105  $this->left = new Border($isSupervisor);
106  $this->right = new Border($isSupervisor);
107  $this->top = new Border($isSupervisor);
108  $this->bottom = new Border($isSupervisor);
109  $this->diagonal = new Border($isSupervisor);
110  $this->diagonalDirection = self::DIAGONAL_NONE;
111 
112  // Specially for supervisor
113  if ($isSupervisor) {
114  // Initialize pseudo-borders
115  $this->allBorders = new Border(true);
116  $this->outline = new Border(true);
117  $this->inside = new Border(true);
118  $this->vertical = new Border(true);
119  $this->horizontal = new Border(true);
120 
121  // bind parent if we are a supervisor
122  $this->left->bindParent($this, 'left');
123  $this->right->bindParent($this, 'right');
124  $this->top->bindParent($this, 'top');
125  $this->bottom->bindParent($this, 'bottom');
126  $this->diagonal->bindParent($this, 'diagonal');
127  $this->allBorders->bindParent($this, 'allBorders');
128  $this->outline->bindParent($this, 'outline');
129  $this->inside->bindParent($this, 'inside');
130  $this->vertical->bindParent($this, 'vertical');
131  $this->horizontal->bindParent($this, 'horizontal');
132  }
133  }
margin left
Definition: langcheck.php:164

Member Function Documentation

◆ applyFromArray()

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

Apply styles from array.

$spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( [ 'bottom' => [ 'borderStyle' => Border::BORDER_DASHDOT, 'color' => [ 'rgb' => '808080' ] ], 'top' => [ 'borderStyle' => Border::BORDER_DASHDOT, 'color' => [ 'rgb' => '808080' ] ] ] );

$spreadsheet->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( [ 'allBorders' => [ 'borderStyle' => Border::BORDER_DASHDOT, 'color' => [ 'rgb' => '808080' ] ] ] );

Parameters
array$pStylesArray containing style information
Returns
$this

Definition at line 197 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\getActiveSheet(), PhpOffice\PhpSpreadsheet\Style\Borders\getBottom(), PhpOffice\PhpSpreadsheet\Style\Borders\getDiagonal(), PhpOffice\PhpSpreadsheet\Style\Borders\getLeft(), PhpOffice\PhpSpreadsheet\Style\Borders\getRight(), PhpOffice\PhpSpreadsheet\Style\Supervisor\getSelectedCells(), PhpOffice\PhpSpreadsheet\Style\Borders\getStyleArray(), PhpOffice\PhpSpreadsheet\Style\Borders\getTop(), and PhpOffice\PhpSpreadsheet\Style\Borders\setDiagonalDirection().

198  {
199  if ($this->isSupervisor) {
200  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
201  } else {
202  if (isset($pStyles['left'])) {
203  $this->getLeft()->applyFromArray($pStyles['left']);
204  }
205  if (isset($pStyles['right'])) {
206  $this->getRight()->applyFromArray($pStyles['right']);
207  }
208  if (isset($pStyles['top'])) {
209  $this->getTop()->applyFromArray($pStyles['top']);
210  }
211  if (isset($pStyles['bottom'])) {
212  $this->getBottom()->applyFromArray($pStyles['bottom']);
213  }
214  if (isset($pStyles['diagonal'])) {
215  $this->getDiagonal()->applyFromArray($pStyles['diagonal']);
216  }
217  if (isset($pStyles['diagonalDirection'])) {
218  $this->setDiagonalDirection($pStyles['diagonalDirection']);
219  }
220  if (isset($pStyles['allBorders'])) {
221  $this->getLeft()->applyFromArray($pStyles['allBorders']);
222  $this->getRight()->applyFromArray($pStyles['allBorders']);
223  $this->getTop()->applyFromArray($pStyles['allBorders']);
224  $this->getBottom()->applyFromArray($pStyles['allBorders']);
225  }
226  }
227 
228  return $this;
229  }
getStyleArray($array)
Build style array from subcomponents.
Definition: Borders.php:153
getSelectedCells()
Get the currently active cell coordinate in currently active sheet.
Definition: Supervisor.php:87
setDiagonalDirection($pValue)
Set DiagonalDirection.
Definition: Borders.php:372
getActiveSheet()
Get the currently active sheet.
Definition: Supervisor.php:76
+ Here is the call graph for this function:

◆ exportArray1()

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

Definition at line 409 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Supervisor\exportArray2(), PhpOffice\PhpSpreadsheet\Style\Borders\getBottom(), PhpOffice\PhpSpreadsheet\Style\Borders\getDiagonal(), PhpOffice\PhpSpreadsheet\Style\Borders\getDiagonalDirection(), PhpOffice\PhpSpreadsheet\Style\Borders\getLeft(), PhpOffice\PhpSpreadsheet\Style\Borders\getRight(), and PhpOffice\PhpSpreadsheet\Style\Borders\getTop().

409  : array
410  {
411  $exportedArray = [];
412  $this->exportArray2($exportedArray, 'bottom', $this->getBottom());
413  $this->exportArray2($exportedArray, 'diagonal', $this->getDiagonal());
414  $this->exportArray2($exportedArray, 'diagonalDirection', $this->getDiagonalDirection());
415  $this->exportArray2($exportedArray, 'left', $this->getLeft());
416  $this->exportArray2($exportedArray, 'right', $this->getRight());
417  $this->exportArray2($exportedArray, 'top', $this->getTop());
418 
419  return $exportedArray;
420  }
getDiagonalDirection()
Get DiagonalDirection.
Definition: Borders.php:356
exportArray2(array &$exportedArray, string $index, $objOrValue)
Populate array from exportArray1.
Definition: Supervisor.php:150
+ Here is the call graph for this function:

◆ getAllBorders()

PhpOffice\PhpSpreadsheet\Style\Borders::getAllBorders ( )

Get AllBorders (pseudo-border).

Only applies to supervisor.

Returns
Border

Definition at line 286 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Borders\$allBorders.

287  {
288  if (!$this->isSupervisor) {
289  throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.');
290  }
291 
292  return $this->allBorders;
293  }

◆ getBottom()

◆ getDiagonal()

◆ getDiagonalDirection()

PhpOffice\PhpSpreadsheet\Style\Borders::getDiagonalDirection ( )

Get DiagonalDirection.

Returns
int

Definition at line 356 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Borders\$diagonalDirection, and PhpOffice\PhpSpreadsheet\Style\Borders\getSharedComponent().

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\exportArray1(), PhpOffice\PhpSpreadsheet\Style\Borders\getHashCode(), and PhpOffice\PhpSpreadsheet\Writer\Xlsx\Style\writeBorder().

357  {
358  if ($this->isSupervisor) {
359  return $this->getSharedComponent()->getDiagonalDirection();
360  }
361 
363  }
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Borders.php:141
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHashCode()

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

Get hash code.

Returns
string Hash code

Implements PhpOffice\PhpSpreadsheet\IComparable.

Definition at line 392 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Borders\getBottom(), PhpOffice\PhpSpreadsheet\Style\Borders\getDiagonal(), PhpOffice\PhpSpreadsheet\Style\Borders\getDiagonalDirection(), PhpOffice\PhpSpreadsheet\Style\Borders\getLeft(), PhpOffice\PhpSpreadsheet\Style\Borders\getRight(), PhpOffice\PhpSpreadsheet\Style\Borders\getSharedComponent(), and PhpOffice\PhpSpreadsheet\Style\Borders\getTop().

393  {
394  if ($this->isSupervisor) {
395  return $this->getSharedComponent()->getHashcode();
396  }
397 
398  return md5(
399  $this->getLeft()->getHashCode() .
400  $this->getRight()->getHashCode() .
401  $this->getTop()->getHashCode() .
402  $this->getBottom()->getHashCode() .
403  $this->getDiagonal()->getHashCode() .
404  $this->getDiagonalDirection() .
405  __CLASS__
406  );
407  }
getDiagonalDirection()
Get DiagonalDirection.
Definition: Borders.php:356
getSharedComponent()
Get the shared style component for the currently active cell in currently active sheet.
Definition: Borders.php:141
+ Here is the call graph for this function:

◆ getHorizontal()

PhpOffice\PhpSpreadsheet\Style\Borders::getHorizontal ( )

Get Horizontal (pseudo-border).

Only applies to supervisor.

Returns
Border

Definition at line 342 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Borders\$horizontal.

343  {
344  if (!$this->isSupervisor) {
345  throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.');
346  }
347 
348  return $this->horizontal;
349  }

◆ getInside()

PhpOffice\PhpSpreadsheet\Style\Borders::getInside ( )

Get Inside (pseudo-border).

Only applies to supervisor.

Returns
Border

Definition at line 314 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Borders\$inside.

315  {
316  if (!$this->isSupervisor) {
317  throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.');
318  }
319 
320  return $this->inside;
321  }

◆ getLeft()

◆ getOutline()

PhpOffice\PhpSpreadsheet\Style\Borders::getOutline ( )

Get Outline (pseudo-border).

Only applies to supervisor.

Returns
Border

Definition at line 300 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Borders\$outline.

301  {
302  if (!$this->isSupervisor) {
303  throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.');
304  }
305 
306  return $this->outline;
307  }

◆ getRight()

◆ getSharedComponent()

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

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

Only used for style supervisor.

Returns
Borders

Definition at line 141 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getDiagonalDirection(), and PhpOffice\PhpSpreadsheet\Style\Borders\getHashCode().

142  {
143  return $this->parent->getSharedComponent()->getBorders();
144  }
+ Here is the caller graph for this function:

◆ getStyleArray()

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

Build style array from subcomponents.

Parameters
array$array
Returns
array

Definition at line 153 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\applyFromArray(), and PhpOffice\PhpSpreadsheet\Style\Borders\setDiagonalDirection().

154  {
155  return ['borders' => $array];
156  }
+ Here is the caller graph for this function:

◆ getTop()

◆ getVertical()

PhpOffice\PhpSpreadsheet\Style\Borders::getVertical ( )

Get Vertical (pseudo-border).

Only applies to supervisor.

Returns
Border

Definition at line 328 of file Borders.php.

References PhpOffice\PhpSpreadsheet\Style\Borders\$vertical.

329  {
330  if (!$this->isSupervisor) {
331  throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.');
332  }
333 
334  return $this->vertical;
335  }

◆ setDiagonalDirection()

PhpOffice\PhpSpreadsheet\Style\Borders::setDiagonalDirection (   $pValue)

Set DiagonalDirection.

Parameters
int$pValuesee self::DIAGONAL_*
Returns
$this

Definition at line 372 of file Borders.php.

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

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\applyFromArray(), and PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles\readBorderStyle().

373  {
374  if ($pValue == '') {
375  $pValue = self::DIAGONAL_NONE;
376  }
377  if ($this->isSupervisor) {
378  $styleArray = $this->getStyleArray(['diagonalDirection' => $pValue]);
379  $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
380  } else {
381  $this->diagonalDirection = $pValue;
382  }
383 
384  return $this;
385  }
getStyleArray($array)
Build style array from subcomponents.
Definition: Borders.php:153
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:
+ Here is the caller graph for this function:

Field Documentation

◆ $allBorders

PhpOffice\PhpSpreadsheet\Style\Borders::$allBorders
protected

Definition at line 62 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getAllBorders().

◆ $bottom

PhpOffice\PhpSpreadsheet\Style\Borders::$bottom
protected

Definition at line 41 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getBottom().

◆ $diagonal

PhpOffice\PhpSpreadsheet\Style\Borders::$diagonal
protected

Definition at line 48 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getDiagonal().

◆ $diagonalDirection

PhpOffice\PhpSpreadsheet\Style\Borders::$diagonalDirection
protected

◆ $horizontal

PhpOffice\PhpSpreadsheet\Style\Borders::$horizontal
protected

Definition at line 90 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getHorizontal().

◆ $inside

PhpOffice\PhpSpreadsheet\Style\Borders::$inside
protected

Definition at line 76 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getInside().

◆ $left

PhpOffice\PhpSpreadsheet\Style\Borders::$left
protected

Definition at line 20 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getLeft().

◆ $outline

PhpOffice\PhpSpreadsheet\Style\Borders::$outline
protected

Definition at line 69 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getOutline().

◆ $right

PhpOffice\PhpSpreadsheet\Style\Borders::$right
protected

Definition at line 27 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getRight().

◆ $top

PhpOffice\PhpSpreadsheet\Style\Borders::$top
protected

Definition at line 34 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getTop().

◆ $vertical

PhpOffice\PhpSpreadsheet\Style\Borders::$vertical
protected

Definition at line 83 of file Borders.php.

Referenced by PhpOffice\PhpSpreadsheet\Style\Borders\getVertical().

◆ DIAGONAL_BOTH

◆ DIAGONAL_DOWN

◆ DIAGONAL_NONE

const PhpOffice\PhpSpreadsheet\Style\Borders::DIAGONAL_NONE = 0

◆ DIAGONAL_UP


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