PHPOffice / PhpSpreadsheet

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

Return value of PhpOffice\PhpSpreadsheet\Shared\File::assertFile() must be an instance of PhpOffice\PhpSpreadsheet\Shared\void, none returned #1536

Closed AlexGnatko closed 4 years ago

AlexGnatko commented 4 years ago

This is:

- [ ] a bug report

What is the expected behavior?

In version 1.5.2, I had no problem. I'm opening an XLSX file as a template and make changes to it, add data, etc. then output the result.

What is the current behavior?

I've tried to update PhpSpreadsheet via composer. Now I get this exception: Return value of PhpOffice\PhpSpreadsheet\Shared\File::assertFile() must be an instance of PhpOffice\PhpSpreadsheet\Shared\void, none returned

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:

<?php

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

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

// add code that show the issue here...
$inputFileName = 'export.xlsx';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
// the error happens in the line above
// the exports.xlsx file can be found here: http://asiamotors78.ru/xls/export.xlsx
// while on the server it is opened as a local file

Which versions of PhpSpreadsheet and PHP are affected?

I tried the latest one (1.13.something) and 1.8.0. Both generate the error. 1.5.2 works with no issues, but GitHub suggests that I update my project's composer.json because of the bad insecure dependency (PhpSpreadsheet version <1.8.0).

Update:

I've tested in on Windows, PHP 7.2.4 as Apache module - version 1.8.0 works fine.

The server is running PHP 7.0 in FastCGI mode (php7.0-fpm) with nginx.

AlexGnatko commented 4 years ago

OK, I've switched the website to PHP 7.2 and now it works with version 1.13.0. So it seems to be a PHP 7.0-only issue.

stale[bot] commented 4 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.