Rectangle 27 63

function cellColor($cells,$color){
    global $objPHPExcel;

    $objPHPExcel->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
        'type' => PHPExcel_Style_Fill::FILL_SOLID,
        'startcolor' => array(
             'rgb' => $color
        )
    ));
}

cellColor('B5', 'F28A8C');
cellColor('G5', 'F28A8C');
cellColor('A7:I7', 'F28A8C');
cellColor('A17:I17', 'F28A8C');
cellColor('A30:Z30', 'F28A8C');

Your functions it's ok, but you are using global, and that's a real error... You should make use of the PHP5 features. Instead, you could try a lambda function such as eval.in/39136 :)

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 62

function cellColor($cells,$color){
    global $objPHPExcel;

    $objPHPExcel->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
        'type' => PHPExcel_Style_Fill::FILL_SOLID,
        'startcolor' => array(
             'rgb' => $color
        )
    ));
}

cellColor('B5', 'F28A8C');
cellColor('G5', 'F28A8C');
cellColor('A7:I7', 'F28A8C');
cellColor('A17:I17', 'F28A8C');
cellColor('A30:Z30', 'F28A8C');

Your functions it's ok, but you are using global, and that's a real error... You should make use of the PHP5 features. Instead, you could try a lambda function such as eval.in/39136 :)

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 62

function cellColor($cells,$color){
    global $objPHPExcel;

    $objPHPExcel->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array(
        'type' => PHPExcel_Style_Fill::FILL_SOLID,
        'startcolor' => array(
             'rgb' => $color
        )
    ));
}

cellColor('B5', 'F28A8C');
cellColor('G5', 'F28A8C');
cellColor('A7:I7', 'F28A8C');
cellColor('A17:I17', 'F28A8C');
cellColor('A30:Z30', 'F28A8C');

Your functions it's ok, but you are using global, and that's a real error... You should make use of the PHP5 features. Instead, you could try a lambda function such as eval.in/39136 :)

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 123

$sheet->getStyle('A1')->applyFromArray(
    array(
        'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => 'FF0000')
        )
    )
);

This was incorrect syntax as of 2013-10-17. I have edited to reflect correct syntax.

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 123

$sheet->getStyle('A1')->applyFromArray(
    array(
        'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => 'FF0000')
        )
    )
);

This was incorrect syntax as of 2013-10-17. I have edited to reflect correct syntax.

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 123

$sheet->getStyle('A1')->applyFromArray(
    array(
        'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'color' => array('rgb' => 'FF0000')
        )
    )
);

This was incorrect syntax as of 2013-10-17. I have edited to reflect correct syntax.

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 20

This code should work for you:

$PHPExcel->getActiveSheet()
        ->getStyle('A1')
        ->getFill()
        ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
        ->getStartColor()
        ->setRGB('FF0000')

But if you bother using this over and over again, I recommend using applyFromArray.

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 20

This code should work for you:

$PHPExcel->getActiveSheet()
        ->getStyle('A1')
        ->getFill()
        ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
        ->getStartColor()
        ->setRGB('FF0000')

But if you bother using this over and over again, I recommend using applyFromArray.

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 20

This code should work for you:

$PHPExcel->getActiveSheet()
        ->getStyle('A1')
        ->getFill()
        ->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
        ->getStartColor()
        ->setRGB('FF0000')

But if you bother using this over and over again, I recommend using applyFromArray.

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 7

Seems like there's a bug with applyFromArray right now that won't accept color, but this worked for me:

$objPHPExcel
    ->getActiveSheet()
    ->getStyle('A1')
    ->getFill()
    ->getStartColor()
    ->setRGB('FF0000');

Though it is more elegant solution (as I prefer OOP way) it didn't worked for me :/ Used @user198003 provided solution

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 7

Seems like there's a bug with applyFromArray right now that won't accept color, but this worked for me:

$objPHPExcel
    ->getActiveSheet()
    ->getStyle('A1')
    ->getFill()
    ->getStartColor()
    ->setRGB('FF0000');

Though it is more elegant solution (as I prefer OOP way) it didn't worked for me :/ Used @user198003 provided solution

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 7

$sheet->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setRGB('FF0000');

IMPORTANT! Than $objPHPExcel like $sheet is a define from object class PHPExcel. You need use like you instantiated (at new PHPExcel() define).

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 7

Seems like there's a bug with applyFromArray right now that won't accept color, but this worked for me:

$objPHPExcel
    ->getActiveSheet()
    ->getStyle('A1')
    ->getFill()
    ->getStartColor()
    ->setRGB('FF0000');

Though it is more elegant solution (as I prefer OOP way) it didn't worked for me :/ Used @user198003 provided solution

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 7

$sheet->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setRGB('FF0000');

IMPORTANT! Than $objPHPExcel like $sheet is a define from object class PHPExcel. You need use like you instantiated (at new PHPExcel() define).

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 7

$sheet->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setRGB('FF0000');

IMPORTANT! Than $objPHPExcel like $sheet is a define from object class PHPExcel. You need use like you instantiated (at new PHPExcel() define).

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 2

$objPHPExcel
->getActiveSheet()
->getStyle('A1')
->getFill()
->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
->getStartColor()
->setRGB('colorcode'); //i.e,colorcode=D3D3D3

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 2

$objPHPExcel
->getActiveSheet()
->getStyle('A1')
->getFill()
->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
->getStartColor()
->setRGB('colorcode'); //i.e,colorcode=D3D3D3

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 2

$objPHPExcel
->getActiveSheet()
->getStyle('A1')
->getFill()
->setFillType(PHPExcel_Style_Fill::FILL_SOLID)
->getStartColor()
->setRGB('colorcode'); //i.e,colorcode=D3D3D3

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 1

$objPHPExcel
    ->getActiveSheet()
    ->getStyle('A1')
    ->getFill()
    ->getStartColor()
    ->getRGB();

Set Background cell color in PHPExcel - Stack Overflow

phpexcel
Rectangle 27 1

$objPHPExcel
    ->getActiveSheet()
    ->getStyle('A1')
    ->getFill()
    ->getStartColor()
    ->getRGB();

Set Background cell color in PHPExcel - Stack Overflow

phpexcel