Ad Code

PHPExcel Make first row bold and add styles

require_once('PHPExcel/Classes/PHPExcel.php');

// create php excel object
$doc = new PHPExcel();

// set active sheet
$doc->setActiveSheetIndex(0);

// Header
//set up the style in an array
$style = array('font' => array('size' => 11,'bold' => true,'color' => array('rgb' => 'ff0000')));

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

// read data to active sheet
$doc->getActiveSheet()->fromArray($dataArray, null, 'A2');

Post a Comment

0 Comments