cell color in RGB?

Topics: Developer Forum, Project Management Forum, User Forum
Mar 30, 2009 at 5:29 PM
I'm trying to set the cell color for a specific cell in my document, but I can't find anywhere that I can use an RGB hex value instead of the ARGB:

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

Something like that, but I want to use the color: e4eaf4
and I can't do it with this :/ Thanks!
Developer
Mar 31, 2009 at 1:33 AM
You can do like this:

$objPHPExcel->getActiveSheet()->getStyle('A18')->getFill()->getStartColor()->setRGB('E4EAF4');

which is the same as this:

$objPHPExcel->getActiveSheet()->getStyle('A18')->getFill()->getStartColor()->setARGB('FFE4EAF4');

Mar 31, 2009 at 12:07 PM
That isn't changing the color of my cell. Are only certain colors supported?
Developer
Mar 31, 2009 at 12:23 PM
Edited Mar 31, 2009 at 12:24 PM
Strange. It is working here.

<?php
$excel = new PHPExcel();

$sheet = $excel->getActiveSheet();
$sheet->getStyle('A18')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle('A18')->getFill()->getStartColor()->setRGB('E4EAF4');

$writer = new PHPExcel_Writer_Excel2007($excel);
$writer->save('write.xlsx');
?>

Mar 31, 2009 at 12:40 PM
In Outlook 2003 and using the converter tool from Microsoft, it just displays that color as a white cell. Maybe it has something to do with the software version?
Developer
Mar 31, 2009 at 12:51 PM
I don't have MS Office 2003 by my hand, can you check with OpenOffice.org 3 ? There it looked as expected too. Tested with both xlsx as well as xls.

Feb 17, 2014 at 12:02 PM
I'm having the same problem and tested with both excel 2003 and openoffice.org 3.