mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-10 18:16:34 +00:00
Merge pull request #3220 from PHPOffice/Issue-3214_Xlsx-Reader-Adjusts-Selected-Cell-when-Loading-CF-Ranges
Store the currently selected cell when loading Conditional Format Ranges, then reset afterwards
This commit is contained in:
@@ -37,19 +37,27 @@ class ConditionalStyles
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
$selectedCells = $this->worksheet->getSelectedCells();
|
||||
|
||||
$this->setConditionalStyles(
|
||||
$this->worksheet,
|
||||
$this->readConditionalStyles($this->worksheetXml),
|
||||
$this->worksheetXml->extLst
|
||||
);
|
||||
|
||||
$this->worksheet->setSelectedCells($selectedCells);
|
||||
}
|
||||
|
||||
public function loadFromExt(StyleReader $styleReader): void
|
||||
{
|
||||
$selectedCells = $this->worksheet->getSelectedCells();
|
||||
|
||||
$this->ns = $this->worksheetXml->getNamespaces(true);
|
||||
$this->setConditionalsFromExt(
|
||||
$this->readConditionalsFromExt($this->worksheetXml->extLst, $styleReader)
|
||||
);
|
||||
|
||||
$this->worksheet->setSelectedCells($selectedCells);
|
||||
}
|
||||
|
||||
private function setConditionalsFromExt(array $conditionals): void
|
||||
|
||||
@@ -8,6 +8,17 @@ use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
|
||||
|
||||
class ConditionalTest extends AbstractFunctional
|
||||
{
|
||||
public function testLoadingConditionalDoesntLoseSelectedCell(): void
|
||||
{
|
||||
$filename = 'tests/data/Reader/XLSX/ConditionalFormat_Ranges.xlsx';
|
||||
$reader = IOFactory::createReader('Xlsx');
|
||||
$spreadsheet = $reader->load($filename);
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
self::assertSame('A1', $worksheet->getActiveCell());
|
||||
self::assertSame('A1', $worksheet->getSelectedCells());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test check if conditional style with type 'notContainsText' works on xlsx.
|
||||
*/
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user