Ad Code

PHPExcel freeze first row and set bgcolor

$default_border = array(
    'style' => PHPExcel_Style_Border::BORDER_THIN,
    'color' => array('rgb'=>'34956c')
);
$style_header = array(
    'borders' => array(
        'bottom' => $default_border,
        'left' => $default_border,
        'top' => $default_border,
        'right' => $default_border
    ),
    'fill' => array(
        'type' => PHPExcel_Style_Fill::FILL_SOLID,
        'color' => array('rgb'=>'005a88')
    ),
    'font' => array(
        'bold' => true,
        'size'  => 10,
        'name'  => 'Comic Sans MS',
        'color' => array('rgb'=>'FFFFFF')
    )
);

$doc->getActiveSheet()->freezePane('A2');

//apply the style on columns
$doc->getActiveSheet()->getStyle('A1:Z1')->applyFromArray($style_header);
$doc->getActiveSheet()->fromArray(array_keys(current($dataArray)), null, 'A1');

Post a Comment

0 Comments