Jump to content

Problem to get bg color using PHPExcle


maxfx

Recommended Posts

hey guys i'm new here and i cannt figure out how to get the bg color of my A5 cell in my excle file it's blue and my code always output me FFFFFF (LINE 14 in the code i paste below)

 

ini_set('include_path', ini_get('include_path').';../Classes/');
require "PHPExcel.php";
require "PHPExcel/Writer/Excel2007.php";

$col_array = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");

$objPHPExcel = new PHPExcel();
$file = "05-2.xls";
//echo $file;
$objReader = PHPExcel_IOFactory::createReaderForFile($file);
$objReader->setReadDataOnly(true);
$objPHPExcel  = $objReader->load($file);
$objWorksheet = $objPHPExcel->setActiveSheetIndex(2);
$objWorksheet = $objPHPExcel->getActiveSheet();

echo $objPHPExcel->getActiveSheet()->getStyle('A5')->getFill()->getStartColor()->getRGB();
var_dump($objWorksheet->getCellByColumnAndRow('0', '5')->getValue());
die;

$highestRow    = $objWorksheet->getHighestRow(); // e.g. 10
$highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F'

$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5

for ($row = 1; $row <= $highestRow; ++$row) {	
if ($row > 3) {		
	  for ($col = 0; $col <= $highestColumnIndex; ++$col) {

		$col_num = $col_array[$col];
		echo $objWorksheet->getCellByColumnAndRow($col, $row)->getValue()."$col_num$row";

		var_dump($objPHPExcel->getActiveSheet()->getStyle($col_num.$row)->getFill()->getStartColor()->getRGB());
	  	
		$row_array[$row][] = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); 
	  }
}
}

Link to comment
https://forums.phpfreaks.com/topic/220832-problem-to-get-bg-color-using-phpexcle/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.