PHPExcel Make first row bold

后端 未结 10 890
猫巷女王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:59

    $objPHPExcel->getActiveSheet()->getStyle("A1:".$objPHPExcel->getActiveSheet()->getHighestDataColumn()."1")->getFont()->setBold(true);
    

    I found this to be a working solution, you can replace the two instances of 1 with the row number. The HighestDataColumn function returns for example C or Z, it gives you the last/highest column that's in the sheet containing any data. There is also getHighestColumn(), that one would include cells that are empty but have styling or are part of other functionality.

提交回复
热议问题