You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- [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?
Document should be readed without any problem, LibreOffice and Microsoft Office do not throw any error on this kind of files.
What is the current behavior?
An exception is thrown when trying to read an Excel document without a styles.xml file inside
TypeError: Argument 1 passed to PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles::__construct() must be an instance of SimpleXMLElement, bool given, called in /var/www/laravel/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php on line 566
<?phprequire__DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$filename = './withoutStylesTest.xlsx';
$reader = newXlsx();
$reader->load($filename);
// add code that show the issue here...
TypeError: Argument 1 passed to PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles::__construct() must be an instance of SimpleXMLElement, bool given, called in /var/www/laravel/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php on line 566
/var/www/laravel/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Styles.php:31
/var/www/laravel/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php:566
/var/www/laravel/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php:86
/var/www/laravel/app/Services/Import/Mapper/BiddingsXlsMapper.php:13
This is an exact replacement for PR PHPOffice#2247 by @arraintxo. That PR has reached a state in Github where it cannot be merged, and I am not sure how to fix it, other than by re-submitting it as this PR.
See issue PHPOffice#2246. A spreadsheet lacking styles.xml is throwing an exception on Read. Additionally, after fixing that problem, attempting to save the object that has been read throws an exception. This is also true for a spreadsheet with an empty styles.xml.
This is:
What is the expected behavior?
Document should be readed without any problem, LibreOffice and Microsoft Office do not throw any error on this kind of files.
What is the current behavior?
An exception is thrown when trying to read an Excel document without a styles.xml file inside
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
withoutStylesTest.xlsx
Which versions of PhpSpreadsheet and PHP are affected?
Checked on PHP 8.0 and PhpSpreadsheet 1.18
The text was updated successfully, but these errors were encountered: