PHPExcel color to specific row

后端 未结 1 1623
旧时难觅i
旧时难觅i 2021-02-05 20:05

I am currently working with PHPExcel and I am trying to give 1 specific row a color, I have read Set Background cell color in PHPExcel already and I have try all of those option

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 20:16

    You cannot style a row in PHPExcel, only a cell or a range of cells

    $objPHPExcel->getActiveSheet()
        ->getStyle('A1:E1')
        ->getFill()
        ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
        ->getStartColor()
        ->setARGB('FF808080');
    

    or

    $objPHPExcel->getActiveSheet()
        ->getStyle('A1:E1')
        ->applyFromArray(
            array(
                'fill' => array(
                    'type' => PHPExcel_Style_Fill::FILL_SOLID,
                    'color' => array('rgb' => 'E05CC2')
                )
            )
        );
    

    Will set the background fill style for cells A1 to E1

    0 讨论(0)
提交回复
热议问题