diff --git a/CHANGELOG.md b/CHANGELOG.md index e89705b171..e7054f1b1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com) and this project adheres to [Semantic Versioning](https://semver.org). -## TBD - 3.0.0 +## 2024-08-07 - 2.2.2 ### Added @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - RATE Function Floating Point Number of Periods. [PR #4107](https://github.com/PHPOffice/PhpSpreadsheet/pull/4107) - Parameter Name Change Xlsx Writer Workbook. [Issue #4108](https://github.com/PHPOffice/PhpSpreadsheet/issues/4108) [PR #4111](https://github.com/PHPOffice/PhpSpreadsheet/pull/4111) - New Algorithm for TRUNC, ROUNDUP, ROUNDDOWN. [Issue #4113](https://github.com/PHPOffice/PhpSpreadsheet/issues/4113) [PR #4115](https://github.com/PHPOffice/PhpSpreadsheet/pull/4115) +- Worksheet applyStylesFromArray Retain Active Cell (Excel 16 was having a problem with some files). [Issue #4128](https://github.com/PHPOffice/PhpSpreadsheet/issues/4128) [PR #4132](https://github.com/PHPOffice/PhpSpreadsheet/pull/4132) ## 2024-07-29 - 2.2.1 diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 7afa82b5d9..39355b3c4f 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -3682,7 +3682,9 @@ public function applyStylesFromArray(string $coordinate, array $styleArray): boo } $activeSheetIndex = $spreadsheet->getActiveSheetIndex(); $originalSelected = $this->selectedCells; + $originalActive = $this->activeCell; $this->getStyle($coordinate)->applyFromArray($styleArray); + $this->activeCell = $originalActive; $this->selectedCells = $originalSelected; if ($activeSheetIndex >= 0) { $spreadsheet->setActiveSheetIndex($activeSheetIndex); diff --git a/tests/PhpSpreadsheetTests/Worksheet/Issue4128Test.php b/tests/PhpSpreadsheetTests/Worksheet/Issue4128Test.php new file mode 100644 index 0000000000..4636310a9f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Worksheet/Issue4128Test.php @@ -0,0 +1,23 @@ +getActiveSheet(); + self::assertSame('A1', $sheet->getActiveCell()); + self::assertSame('A1', $sheet->getSelectedCells()); + $sheet->setCellValue('D1', 'MyDate'); + self::assertSame('A1', $sheet->getActiveCell()); + self::assertSame('A1', $sheet->getSelectedCells()); + $spreadsheet->disconnectWorksheets(); + } +}