Borders - ApplyFromArray() - Slow on large spreadsheet

Topics: Developer Forum
Jun 12, 2012 at 3:40 PM

First of all thanks all the effort is creating this excellent library!

I am generating a large dynamic xls doc. Using the fromArray() method I'm able to generate a large output super fast, approx. 2000 rows x 200 columns and sometimes larger. The doc generates in +- 15secs. The issue comes in when I use ApplyFromArray to apply a border style, then processing time hops right up to 400secs. This I can understand as PHPExcel appears to iterate over each cell per row per column to apply the style. My quesion... is there no other way(faster) to apply borders, maybe like a default setting per worksheet, similar to the methods like:

...->getDefaultStyle()->getFont()->setName('Arial');
...->getDefaultStyle()->getFont()->setSize(9);

Many thanks, BGE

Coordinator
Jun 13, 2012 at 10:06 PM

Are you applying getStyle() with a range of cells?

$styleArray = array(
  'borders' => array(
    'inside'     => array(
      'style' => PHPExcel_Style_Border::BORDER_THIN,
      'color' => array(
        'argb' => 'FFFF0000'
      )
    ),
    'outline'     => array(
      'style' => PHPExcel_Style_Border::BORDER_THIN,
      'color' => array(
         'argb' => 'FFFF0000'
      )
    )
  )
);
$objPHPExcel->getActiveSheet()->getStyle('A1:E5')->applyFromArray($styleArray);