php - PHPExcel Make first row bold -


i trying make cells in first row bold.

this method have created purpose.

function exporttoexcel($tittles,$excel_name)  {   $objphpexcel = new phpexcel();   $objrichtext = new phpexcel_richtext();   // set properties   $objphpexcel->getproperties()->setcreator("sample1");   $objphpexcel->getproperties()->setlastmodifiedby("sample1");   $objphpexcel->getproperties()->settitle("sample1");   $objphpexcel->getproperties()->setsubject("sample1");   $objphpexcel->getproperties()->setdescription("sample1");     // add data   $objphpexcel->setactivesheetindex(0);    $letters = range('a','z');   $count =0;   $cell_name="";   foreach($tittles $tittle)   {    $cell_name = $letters[$count]."1";    $count++;    $value = $tittle;    $objphpexcel->getactivesheet()->setcellvalue($cell_name, $value);    // make bold cells    $objphpexcel->getactivesheet()->getstyle($cell_name)->getfont()->setbold(true);   }   // save excel 2007 file   $objwriter = new phpexcel_writer_excel2007($objphpexcel);   //$objwriter->save(str_replace('.php', '.xlsx', __file__));   $objwriter->save($excel_name.".xlsx");  } 

the problem in output excel file cells not bold.

try this

$objphpexcel->getactivesheet()->getstyle("$cell_name:$cell_name")->getfont()->setbold(true); 

hope helps


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -