PhpSpreadsheet can't load xlsx files created by itself

Created on 18 Jan 2019  路  4Comments  路  Source: PHPOffice/PhpSpreadsheet

This is:

- [X] a bug report

The package is unable to load xlsx files created by itself with fatal error. There is no issue loading files created by Google Sheets (I don't have MS Office installed). The test.xlsx file was created by Google Sheets.

Test script

<?php
// test.php
include 'vendor/autoload.php';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('test.xlsx');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx");
$writer->save('output.xlsx');
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('output.xlsx');

What is the expected behavior?

Excel file loaded into the $preadsheet variable

What is the current behavior?

Fatal error: Uncaught Error: Call to a member function children() on bool in C:\...\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Reader\Xlsx.php:1633
Stack trace:
#0 C:\...\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\IOFactory.php(95): PhpOffice\PhpSpreadsheet\Reader\Xlsx->load('out.xlsx')
#1 C:\...\test.php(7): PhpOffice\PhpSpreadsheet\IOFactory::load('out.xlsx')
#2 {main}
  thrown in C:\...\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Reader\Xlsx.php on line 1633

Which versions of PhpSpreadsheet and PHP are affected?

PHP 7.3.1
PhpSpreadsheet 1.6.0

Edit:
If I comment everything related to reading drawings everything works fine.

Most helpful comment

This also cause an error message when opening the result file in MS Excel, but it is recoverable.

All 4 comments

The test file:
test.xlsx

This also cause an error message when opening the result file in MS Excel, but it is recoverable.

Looking forward to this fix. Thank you for all the hard work.

Please, merge my pull request too, method load has notice and errors without my pull request

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexbog8 picture alexbog8  路  4Comments

ariefbayu picture ariefbayu  路  3Comments

PowerKiKi picture PowerKiKi  路  5Comments

Typel picture Typel  路  5Comments

emeraldjava picture emeraldjava  路  4Comments