PhpSpreadsheet: ZipStream\ZipStream::__construct(): Argument #1 ($comment) must be of type string, null given, called in \vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\ZipStream2.php on line 19

This is:

- [

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

// add code that show the issue here...

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Which versions of PhpSpreadsheet and PHP are affected?

About this issue

Most upvoted comments

I had the same problem with Codeigniter on Ubuntu server. I solved this way. I removed Spreadsheet with Composer. I cleared the cache with Composer. I deleted all the vendor folder. I installed Spreadsheet with composer. I uploaded all new vendor folder. it worked.

Php 8.2 CI 4.3.5

I hope it can help

I found a bad solution but I needed urgently, changing vendor class: file: ZipStream0.php

Code:

namespace PhpOffice\PhpSpreadsheet\Writer;

use ZipStream\Option\Archive;
use ZipStream\ZipStream;

class ZipStream0
{
    /**
     * @param resource $fileHandle
     */
    public static function newZipStream($fileHandle): ZipStream
    {
        /* the problem is in ZipStream2
        return class_exists(Archive::class) ? ZipStream2::newZipStream($fileHandle) : ZipStream3::newZipStream($fileHandle);
        */
        return ZipStream3::newZipStream($fileHandle);
    }
}

Adding this dependency to my composer.json did workaround the issue:

		"maennchen/zipstream-php": "3.0.*",

I guess the quick fix for this issue is to just adjust the dependency version of maennchen/zipstream-php in this repository in a similar fashion since minor version updates of that dependency seemingly are not backwards compatible.

For php 8.2 compatibility it appears

		"myclabs/php-enum": "^1.8",

also needs to be added.