Skip to content

Commit

Permalink
Performance Improvement for Xlsx Reader (#3810)
Browse files Browse the repository at this point in the history
* Performance Improvement for Xlsx Reader

Fix #3683. PR #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.

* Very Minor Improvement

* Update CHANGELOG.md
  • Loading branch information
oleibman authored Dec 6, 2023
1 parent df3c6d9 commit 0fddcc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Slk Shared Formulas. [Issue #2267](https://github.com/PHPOffice/PhpSpreadsheet/issues/2267) [PR #3776](https://github.com/PHPOffice/PhpSpreadsheet/pull/3776)
- Html omitting some charts. [Issue #3767](https://github.com/PHPOffice/PhpSpreadsheet/issues/3767) [PR #3771](https://github.com/PHPOffice/PhpSpreadsheet/pull/3771)
- Case Insensitive Comparison for Sheet Names [PR #3791](https://github.com/PHPOffice/PhpSpreadsheet/pull/3791)
- Performance improvement for Xlsx Reader. [Issue #3683](https://github.com/PHPOffice/PhpSpreadsheet/issues/3683) [PR #3810](https://github.com/PHPOffice/PhpSpreadsheet/pull/3810)
- Prevent loop in Shared/File. [Issue #3807](https://github.com/PHPOffice/PhpSpreadsheet/issues/3807) [PR #3809](https://github.com/PHPOffice/PhpSpreadsheet/pull/3809)

## 1.29.0 - 2023-06-15

Expand Down
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 ($cellDataType === DataType::TYPE_FORMULA && $styles[$cAttrS]->quotePrefix === true) {
$cell->getStyle()->setQuotePrefix(false);
}
$docSheet->setSelectedCells($holdSelected);
Expand Down

0 comments on commit 0fddcc1

Please sign in to comment.