I want to copy the style information from cells to ranges, like Format Painter in Excel. The documentation says to do something like this:
$activeSheet->duplicateStyle($activeSheet->getStyle('A1'), 'D1:D100');
$activeSheet->duplicateStyle($activeSheet->getStyle('B1'), 'E1:E100');
There appears to be a bug because both D1:D100 and E1:E100 get the style from cell B1. If I change the order of the two lines, both ranges get the style from A1. Similarly,
$styleA = $activeSheet->getStyle('A1');
$styleB = $activeSheet->getStyle('B1');
$activeSheet->duplicateStyle($styleA, 'D1:D100');
results in D1:D100 getting style info from cell B1. The last getStyle value is used in all duplicateStyle results.
I'm sure that a future release of PHPExcel will have a fix, I just need to figure out a work-around until then.
One workround for you might be to use the style xf Indexes:
Then to set that value for the xfIndex of all cells in the range
EDIT
Alternatively, apply fix to the duplicateStyle() method in Classes/PHPExcel/Worksheet.php
lines 1479 to 1486 currently read:
change to:
Similarly in the applyFromArray() method in Classes/PHPExcel/Style.php
lines 425 to 432 currently read:
change to:
EDIT #2
Fix has now been pushed to the develop branch on github. It does give a slight performance hit, depending on the number of styles in use... I'll try and get a faster version tomorrow night