PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.4k stars 3.48k forks source link

Error loading Xls file with empty documentSummaryInformation #1882

Open sebluy opened 3 years ago

sebluy commented 3 years ago

This is:

- [ x] a bug report
- [ ] a feature request
- [ ] **not** a usage question

What is the expected behavior?

The Excel file should load.

What is the current behavior?

I'm getting the following error:

PHP Error[8]: Uninitialized string offset: 27 in file .../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php at line 7959

0 .../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php(1538): getInt4d()

1 .../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls.php(645): PhpOffice\PhpSpreadsheet\Reader\Xls->readDocumentSummaryInformation()

PhpOffice\PhpSpreadsheet\Reader\Xls->load()

What are the steps to reproduce?

I'm not sure how to reproduce this one. When the code gets to readDocumentSummaryInformation(), the stream is empty but not null, and the code crashes. The problem only happens when I try to open certain files. The files open fine in LibreOffice, and if I re-save them using LibreOffice, then they open fine with PhpSpreadsheet. I'm not sure if this is necessarily a bug, or if the files I'm using are somehow corrupt. The files contain sensitive information so I can't upload them. Regardless, I thought I'd post this here in case it is a bug.

Which versions of PhpSpreadsheet and PHP are affected?

Tested on PHP 7.2.24, and PhpSpreadsheet 1.16 and 1.11.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue for you, please try to help by debugging it further and sharing your results. Thank you for your contributions.