Styling through applyFromArray() takes longer for each extra worksheet

Topics: Developer Forum
Oct 12, 2013 at 4:03 PM
Edited Oct 12, 2013 at 4:05 PM
I have encountered a problem and was wondering if someone else had a good solution.

I am creating quite a large excel file:
10+ worksheet, each with 15k rows, and 10 columns.

I am setting a couple of markup things through a column iterator.

My code looks something like:
<?php
foreach($columns as $key => $col_name){
$column_style = array();
$column_style['font']['size'] = '10';
etc etc
if($key%2){
$column_style['fill'] etc etc
}

$objPHPExcel->getActiveSheet()->getStyle($col_name.'3:'.$col_name.''.$highestRow)->applyFromArray($column_style);                           
}   
?>
I have noticed that if I create a file with the 7 of the same worksheets, (15k rows, 10 columns, exactly the same), each time $objPHPExcel->getActiveSheet()->getStyle($col_name.'3:'.$col_name.''.$highestRow)->applyFromArray($column_style);
Takes 4 seconds longer to apply.

So in the 7th worksheet the application of the style (on sheet 7) takes 33.2 seconds (instead of 6 seconds for the first worksheet).

Any suggestions?