PHPExcel Make first row bold

后端 未结 10 885
猫巷女王i
猫巷女王i 2020-12-13 03:34

I am trying to make cells in first row are bold.

This is the method I have created for that purpose.

function ExportToExcel($tittles,$excel_name)
 {
         


        
10条回答
  •  一个人的身影
    2020-12-13 03:52

    This iterates through a variable number of columns of a particular row, which in this case is the 1st row:

    $rownumber = 1;
    $row = $this->objPHPExcel->getActiveSheet()->getRowIterator($rownumber)->current();
    
    $cellIterator = $row->getCellIterator();
    $cellIterator->setIterateOnlyExistingCells(false);
    
    foreach ($cellIterator as $cell) {
        $cell->getStyle()->getFont()->setBold(true);
    }
    

提交回复
热议问题