You are here

public function PHPExcel_Style_Borders::applyFromArray in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Borders.php \PHPExcel_Style_Borders::applyFromArray()

Apply styles from array

<code> $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, 'color' => array( 'rgb' => '808080' ) ), 'top' => array( 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, 'color' => array( 'rgb' => '808080' ) ) ) ); </code> <code> $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray( array( 'allborders' => array( 'style' => PHPExcel_Style_Border::BORDER_DASHDOT, 'color' => array( 'rgb' => '808080' ) ) ) ); </code>

Parameters

array $pStyles Array containing style information:

Return value

PHPExcel_Style_Borders

Throws

PHPExcel_Exception

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Borders.php, line 227

Class

PHPExcel_Style_Borders
PHPExcel_Style_Borders

Code

public function applyFromArray($pStyles = null) {
  if (is_array($pStyles)) {
    if ($this->_isSupervisor) {
      $this
        ->getActiveSheet()
        ->getStyle($this
        ->getSelectedCells())
        ->applyFromArray($this
        ->getStyleArray($pStyles));
    }
    else {
      if (array_key_exists('left', $pStyles)) {
        $this
          ->getLeft()
          ->applyFromArray($pStyles['left']);
      }
      if (array_key_exists('right', $pStyles)) {
        $this
          ->getRight()
          ->applyFromArray($pStyles['right']);
      }
      if (array_key_exists('top', $pStyles)) {
        $this
          ->getTop()
          ->applyFromArray($pStyles['top']);
      }
      if (array_key_exists('bottom', $pStyles)) {
        $this
          ->getBottom()
          ->applyFromArray($pStyles['bottom']);
      }
      if (array_key_exists('diagonal', $pStyles)) {
        $this
          ->getDiagonal()
          ->applyFromArray($pStyles['diagonal']);
      }
      if (array_key_exists('diagonaldirection', $pStyles)) {
        $this
          ->setDiagonalDirection($pStyles['diagonaldirection']);
      }
      if (array_key_exists('allborders', $pStyles)) {
        $this
          ->getLeft()
          ->applyFromArray($pStyles['allborders']);
        $this
          ->getRight()
          ->applyFromArray($pStyles['allborders']);
        $this
          ->getTop()
          ->applyFromArray($pStyles['allborders']);
        $this
          ->getBottom()
          ->applyFromArray($pStyles['allborders']);
      }
    }
  }
  else {
    throw new PHPExcel_Exception("Invalid style array passed.");
  }
  return $this;
}