public function PHPExcel_Style_Font::applyFromArray in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Font.php \PHPExcel_Style_Font::applyFromArray()
* Apply styles from array * * <code> * $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray( * array( * 'name' => 'Arial', * 'bold' => TRUE, * 'italic' => FALSE, * 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE, * 'strike' => FALSE, * 'color' => array( * 'rgb' => '808080' * ) * ) * ); * </code> * *
Parameters
array $pStyles Array containing style information: * @throws PHPExcel_Exception * @return PHPExcel_Style_Font
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Style/ Font.php, line 187
Class
- PHPExcel_Style_Font
- PHPExcel_Style_Font
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('name', $pStyles)) {
$this
->setName($pStyles['name']);
}
if (array_key_exists('bold', $pStyles)) {
$this
->setBold($pStyles['bold']);
}
if (array_key_exists('italic', $pStyles)) {
$this
->setItalic($pStyles['italic']);
}
if (array_key_exists('superScript', $pStyles)) {
$this
->setSuperScript($pStyles['superScript']);
}
if (array_key_exists('subScript', $pStyles)) {
$this
->setSubScript($pStyles['subScript']);
}
if (array_key_exists('underline', $pStyles)) {
$this
->setUnderline($pStyles['underline']);
}
if (array_key_exists('strike', $pStyles)) {
$this
->setStrikethrough($pStyles['strike']);
}
if (array_key_exists('color', $pStyles)) {
$this
->getColor()
->applyFromArray($pStyles['color']);
}
if (array_key_exists('size', $pStyles)) {
$this
->setSize($pStyles['size']);
}
}
}
else {
throw new PHPExcel_Exception("Invalid style array passed.");
}
return $this;
}