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

Error exporting excel,zipstream usage error #4146

Closed
sonkwl opened this issue Aug 23, 2024 · 5 comments
Closed

Error exporting excel,zipstream usage error #4146

sonkwl opened this issue Aug 23, 2024 · 5 comments

Comments

@sonkwl
Copy link

sonkwl commented Aug 23, 2024

My code.

$write=IOFactory::createWriter($spreadsheet,"Xlsx");
$write->save("php://output");

Specific errors are reported as follows

<br />
<b>Fatal error</b>:  Uncaught TypeError: ZipStream\ZipStream::__construct(): Argument #1 ($operationMode) must be of type ZipStream\OperationMode, null given, called in /usr/share/nginx/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream2.php on line 19 and defined in /usr/share/nginx/html/vendor/maennchen/zipstream-php/src/ZipStream.php:207
Stack trace:
#0 /usr/share/nginx/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream2.php(19): ZipStream\ZipStream-&gt;__construct()
#1 /usr/share/nginx/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php(15): 

Locating Error Codes

phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream2.php on line 19

19 return new ZipStream(null, $options);

The error appears to be due to incorrect use of the constructor。

How I handle it.

phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/ZipStream0.php

public static function newZipStream($fileHandle): ZipStream
    {
        //source code
        //return class_exists(Archive::class) ? ZipStream2::newZipStream($fileHandle) :ZipStream3::newZipStream($fileHandle);
        return class_exists(Archive::class) ? ZipStream3::newZipStream($fileHandle) :ZipStream3::newZipStream($fileHandle);
    }

compulsory use “ZipStream3::newZipStream”.

version information

  • php8.2
  • phpoffice/phpspreadsheetV2.2

Originally posted by @sonkwl in #4145 (comment)

@oleibman
Copy link
Collaborator

You have added comments to issue #4145 that clearly should have been added to this one. Please delete the comments there and re-add them here.

@oleibman
Copy link
Collaborator

As for your issue, you have a problem with Composer, possibly related to how it caches its information. See #3615 (comment) for steps to correct it.

@sonkwl
Copy link
Author

sonkwl commented Aug 23, 2024

Thank you for your reply.
My project handles network isolation status and cannot be updated directly using composer. My guess would be the zipstream version issue.
I see #3615 issuse is open.Are there any plans to fix this issuse?Or add a new version error alert.

@oleibman
Copy link
Collaborator

The issue is open only so that the fix to the Composer problem is easily available to those experiencing the problem. There is no problem to fix in PhpSpreadsheet in a properly configured environment.

@oleibman
Copy link
Collaborator

oleibman commented Oct 7, 2024

Closing as duplicate of #3615, which has suggestions for fixing the problem.

@oleibman oleibman closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants