Skip to content

Commit

Permalink
Performance Improvement for Xlsx Reader
Browse files Browse the repository at this point in the history
Fix PHPOffice#3683. PR PHPOffice#3497 fixed a problem involving formulas and the quotePrefix style attribute. It did so by automatically turning off quotePrefix for any formulas encountered by Xlsx Reader. Under the right circumstances, it turns out that that change can cause a file read to take noticeably more time than previously. This change will turn off quotePrefix only if it is already on, and that appears to eliminate the performance problem while continuing to solve the original problem.
  • Loading branch information
oleibman committed Dec 3, 2023
1 parent 9fcfa4b commit 37e07cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/PhpSpreadsheet/Reader/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -937,10 +937,10 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet
$holdSelected = $docSheet->getSelectedCells();
$cAttrS = (int) ($cAttr['s'] ?? 0);
// no style index means 0, it seems
$cell->setXfIndex(isset($styles[$cAttrS])
? $cAttrS : 0);
$cAttrS = isset($styles[$cAttrS]) ? $cAttrS : 0;
$cell->setXfIndex($cAttrS);
// issue 3495
if ($cell->getDataType() === DataType::TYPE_FORMULA) {
if ($cell->getDataType() === DataType::TYPE_FORMULA && $styles[$cAttrS]->quotePrefix === true) {
$cell->getStyle()->setQuotePrefix(false);
}
$docSheet->setSelectedCells($holdSelected);
Expand Down

0 comments on commit 37e07cf

Please sign in to comment.