1
$cond1 = new PHPExcel_Style_Conditional();
$cond1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT)->
        setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT)->
        setText('yes');
$cond1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW); 

This code changes the value of the background of the cell to yellow. How to change the background to all the cells in a row?

Now:

If the value of the cell is "yes", then change the background of the cells.

Seeking:

If the value of the cell is "yes", then change the background to all the cells in the row.

  • check out the answer on https://stackoverflow.com/questions/27981676/phpexcel-color-to-specific-row straight from phpexcel developer – Tanmay Vaishya Dec 19 '17 at 07:50

1 Answers1

2

answer from PHPExcel color to specific row straight from its developer.

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