Strange behavior when using CellBackColor (process dies)

Topics: Developer Forum, User Forum
Dec 19, 2011 at 2:52 PM
Edited Dec 19, 2011 at 2:54 PM

Hi all,

i have a strange story for you:

I'm using Version 1.7.6 since a year now. Just included it into an actual project. No big thing, just creating an xls with about 30 cols and 50 rows.
Did it, tested it, worked like a charm, uploaded it from "testing" to "live".

Now, the fun part starts.

With my test environment (Windows 7, XAMPP) everything runs nice.

At the live system, the script simply dies silently (even with 'error_reporting(E_ALL);'). No file was written, so i first thought, it's some problem with the access-rights.

A few (ok, roughly 8 hours) later, i found, that setting cell backcolor is the bad thing. Without backcolor (and it's for about 20 cells only) the script is running and produces a nice and shiny xls.

Even trying different approaches ( setRGB, setARGB, using palette) won't help.

So, i'm looking very puzzled at the moment. Having no clue, what's going wrong there. My last code approach was like this:

 

$objPHPExcel->getActiveSheet()->getStyle($ColRow)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle($ColRow)->getFill()->getStartColor()->setRGB($BColor);

 

Where $BColor ist something valid (even tried fixed "0000FF" for blue and "FF0000FF" for the setARGB approach.

I just don't get it, why it works perfectly local and crashes (without notice) at the live system.

Has anyone fighted with this kind of problem before?

Thanks

Marc

Dec 19, 2011 at 4:42 PM

Not sure but try this instead...

$format_blue = array(
	'fill' => array(
		'type' => PHPExcel_Style_Fill::FILL_SOLID,
		'color' => array('argb' => 'FF0000FF'), //blue
	),
);

$objPHPExcel->getActiveSheet()->getStyle($cell)->applyFromArray($format_blue);

Dec 22, 2011 at 8:59 AM

I think that's a memory_limit and max_execution_time problem in your php.ini. PHPExcel use so much memory

I had the same crashes with all my script PHPExcel. I increased these 2 values and now everything works fine on local server and remote server.

Try to use these functions at the top of your scripts : set_time_limit(xx); ini_set('memory_limit','XXXM');

Or set it in a .htaccess file with : php_value max_execution_time XXX,  php_value memory_limit XXXM