-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Description
As I only found out when looking at the source code, this doesn't work as expected:
<?php
require __DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$first = $sheet->getStyle('A1:A10');
$second = $sheet->getStyle('A1:B10');
$first->applyFromArray(
[
'fill' => [
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR,
'rotation' => 90,
'startcolor' => [
'argb' => 'FFFFFF',
],
'endcolor' => [
'argb' => 'FFA0A0A0',
],
]
]
);
$second->applyFromArray(
['fill' =>
[
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
'color' => ['argb' => 'FFe7c16a'],
]
]
);
$second->applyFromArray(['fill' =>
[
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
'color' => ['argb' => 'FFe7c16a'],
]
]);The reason is that getStyle set the selected range. So when we do the second getStyle it overrides the first call. This is very confusion, especially since the name is getStyle
Proposal
It would be nice if the returned object holds the affected cells.
If that is too complicated, maybe just rename getStyle, so that it is clear it sets the selected cells.
Which versions of PhpSpreadsheet and PHP are affected?
1.0.0
Metadata
Metadata
Assignees
Labels
No labels