PHPExcel: how to get style from a row or range of cells and apply to another

I am trying to get a line style, for example. ("A3: V3"), pass it to the array, and then use this array with the applyFromArray(); function applyFromArray(); .

Here is what I tried:

 $objPHPExcel = $objReader->load($inputFileName); $sheet = $objPHPExcel->getActiveSheet(); $style = $sheet->getStyle("A3:V3"); $sheet->getStyle("A$totalRows:V$totalRows")->applyFromArray($style); 

This results in an "Invalid style array" error .

Is there any workaround for this?

+5
source share
1 answer

I found this in the docs - "If you want to copy the ruleset into other cells, you can duplicate the style object"

$objPHPExcel->getActiveSheet()->duplicateStyle($objPHPExcel->getActiveSheet()->getStyle('B2'), 'B3:B7');

So I no longer needed to do this. Should have just found a little more.

+4
source

All Articles