@wilmer.lemke
To set cell color in PHPExcel, you can use the following code:
1
|
require 'PHPExcel/Classes/PHPExcel.php'; |
1
|
$objPHPExcel = new PHPExcel(); |
1 2 |
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('A1')->getFill()->getStartColor()->setRGB('FF0000'); |
In the above example, we set the color of cell 'A1' to red.
1 2 |
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('test.xlsx'); |
Note: Make sure you have included the PHPExcel library in your project and have the appropriate write permissions for the directory where you are saving the Excel file.