| @@ -352,19 +352,19 @@ | ||
| 352 | 352 | self::updateIfCellIsTableHeader(($nullsafeVariable6 = $this->getParent()) ? $nullsafeVariable6->getParent() : null, $this, $oldValue, $value); |
| 353 | 353 | $worksheet = $this->getWorksheet(); |
| 354 | 354 | $spreadsheet = $worksheet->getParent(); |
| 355 | 355 | if (isset($spreadsheet) && $spreadsheet->getIndex($worksheet, true) >= 0) { |
| 356 | - $originalSelected = $worksheet->getSelectedCells(); | |
| 357 | - $activeSheetIndex = $spreadsheet->getActiveSheetIndex(); | |
| 358 | - $style = $this->getStyle(); | |
| 359 | - $oldQuotePrefix = $style->getQuotePrefix(); | |
| 356 | + // Avoid Worksheet::getStyle() (selection + validation) unless quotePrefix must change. | |
| 357 | + $oldQuotePrefix = $spreadsheet->getCellXfByIndex($this->getXfIndex())->getQuotePrefix(); | |
| 360 | 358 | if ($oldQuotePrefix !== $quotePrefix) { |
| 361 | - $style->setQuotePrefix($quotePrefix); | |
| 359 | + $originalSelected = $worksheet->getSelectedCells(); | |
| 360 | + $activeSheetIndex = $spreadsheet->getActiveSheetIndex(); | |
| 361 | + $this->getStyle()->setQuotePrefix($quotePrefix); | |
| 362 | + $worksheet->setSelectedCells($originalSelected); | |
| 363 | + if ($activeSheetIndex >= 0) { | |
| 364 | + $spreadsheet->setActiveSheetIndex($activeSheetIndex); | |
| 365 | + } | |
| 362 | 366 | } |
| 363 | - $worksheet->setSelectedCells($originalSelected); | |
| 364 | - if ($activeSheetIndex >= 0) { | |
| 365 | - $spreadsheet->setActiveSheetIndex($activeSheetIndex); | |
| 366 | - } | |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | return (($nullsafeVariable7 = $this->getParent()) ? $nullsafeVariable7->get($cellCoordinate) : null) ?? $this; |
| 370 | 370 | } |
| @@ -973,8 +973,20 @@ | ||
| 973 | 973 | { |
| 974 | 974 | $this->xfIndex = $indexValue; |
| 975 | 975 | |
| 976 | 976 | return $this->updateInCollection(); |
| 977 | + } | |
| 978 | + /** | |
| 979 | + * Set the XF index without triggering updateInCollection(). | |
| 980 | + * | |
| 981 | + * This is intended for use by readers that will immediately follow with | |
| 982 | + * setValueExplicit(), avoiding a redundant cache write. | |
| 983 | + * | |
| 984 | + * @internal | |
| 985 | + */ | |
| 986 | + public function setXfIndexNoUpdate(int $indexValue): void | |
| 987 | + { | |
| 988 | + $this->xfIndex = $indexValue; | |
| 977 | 989 | } |
| 978 | 990 | /** |
| 979 | 991 | * Set the formula attributes. |
| 980 | 992 | * |