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

ignoredErrors causing memory exhaustion #4375

Open
nbalena28 opened this issue Feb 19, 2025 · 1 comment · May be fixed by #4377
Open

ignoredErrors causing memory exhaustion #4375

nbalena28 opened this issue Feb 19, 2025 · 1 comment · May be fixed by #4377

Comments

@nbalena28
Copy link

This is:

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

What is the current behavior?
It is throwing an Allowed memory size of bytes exhausted exception

What are the steps to reproduce?
Here is an Excel file to reproduce this behavior with sample.xlsx

$reader = IOFactory::createReader('Xlsx');
$spreadsheet = $reader->load('sample.xlsx');

What features do you think are causing the issue

$sqref = (string) ($attributes['sqref'] ?? '');
$numberStoredAsText = (string) ($attributes['numberStoredAsText'] ?? '');
$formula = (string) ($attributes['formula'] ?? '');
$twoDigitTextYear = (string) ($attributes['twoDigitTextYear'] ?? '');
$evalError = (string) ($attributes['evalError'] ?? '');

Image

The processIgnoredErrors is iterating IT (254) upto 62680 rows

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

Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet 1.29.6 upto 4.0
PHP 7.4 | 8.3

@oleibman
Copy link
Collaborator

Not that it matters, but where is this bogus data coming from? Not one of the gazillion cells identified in the "ignore errors" range even exists.

I think ignored errors should not be processed if you specify readDataOnly. I will make that change. That should fix the memory problem for your sheet, and also greatly reduce the run time.

If readDataOnly is not an option, I also think ignored errors should not be processed for cells that don't exist. I will make that change. That should fix the memory problem for your sheet. It will, unfortunately, not have much effect on run time - we will still need to check the existence of each of the cells.

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Feb 20, 2025
Fix PHPOffice#4375. Do not set ignoredErrors when using readDataOnly, not when the cell to which it applies doesn't exist.
@oleibman oleibman linked a pull request Feb 20, 2025 that will close this issue
11 tasks
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.

2 participants