Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xlsx Reader Formula with quotePrefix caused huge regression in Xlsx reading performance #3683

Closed
1 of 8 tasks
paolobarbolini opened this issue Aug 22, 2023 · 0 comments · Fixed by #3810
Closed
1 of 8 tasks

Comments

@paolobarbolini
Copy link

This is:

- [x] a bug report
- [ ] a feature request
- [x] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

I expect IOFactory::load($filename) to take a reasonable amount of time compared to IOFactory::load($filename, IReader::READ_DATA_ONLY).

What is the current behavior?

We have a file that starting from #3497 (1.29.0) takes up to 5x longer to load without IReader::READ_DATA_ONLY compared to not specifying any flags.

What are the steps to reproduce?

Put this file in the PHP directory: Reproducer.xlsx

<?php

require __DIR__ . '/vendor/autoload.php';

$sheet = \PhpOffice\PhpSpreadsheet\IOFactory::load("Reproducer.xlsx" /*, \PhpOffice\PhpSpreadsheet\Reader\IReader::READ_DATA_ONLY */ );

Comment out

$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
to fix the regression.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

.xlsx

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet 1.29.0
This has been tested on PHP 8.1.22 and PHP 8.2.9

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Dec 3, 2023
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.
oleibman added a commit that referenced this issue Dec 6, 2023
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant