You are here

public function PHPExcel_Style_Alignment::applyFromArray in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Alignment.php \PHPExcel_Style_Alignment::applyFromArray()

* Apply styles from array * * <code> * $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray( * array( * 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, * 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER, * 'rotation' => 0, * 'wrap' => TRUE * ) * ); * </code> * *

Parameters

array $pStyles Array containing style information: * @throws PHPExcel_Exception * @return PHPExcel_Style_Alignment

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Alignment.php, line 171

Class

PHPExcel_Style_Alignment
PHPExcel_Style_Alignment

Code

public function applyFromArray($pStyles = NULL) {
  if (is_array($pStyles)) {
    if ($this->_isSupervisor) {
      $this
        ->getActiveSheet()
        ->getStyle($this
        ->getSelectedCells())
        ->applyFromArray($this
        ->getStyleArray($pStyles));
    }
    else {
      if (isset($pStyles['horizontal'])) {
        $this
          ->setHorizontal($pStyles['horizontal']);
      }
      if (isset($pStyles['vertical'])) {
        $this
          ->setVertical($pStyles['vertical']);
      }
      if (isset($pStyles['rotation'])) {
        $this
          ->setTextRotation($pStyles['rotation']);
      }
      if (isset($pStyles['wrap'])) {
        $this
          ->setWrapText($pStyles['wrap']);
      }
      if (isset($pStyles['shrinkToFit'])) {
        $this
          ->setShrinkToFit($pStyles['shrinkToFit']);
      }
      if (isset($pStyles['indent'])) {
        $this
          ->setIndent($pStyles['indent']);
      }
      if (isset($pStyles['readorder'])) {
        $this
          ->setReadorder($pStyles['readorder']);
      }
    }
  }
  else {
    throw new PHPExcel_Exception("Invalid style array passed.");
  }
  return $this;
}