mk-j / PHP_XLSXWriter

Lightweight XLSX Excel Spreadsheet Writer in PHP
MIT License
1.84k stars 665 forks source link

Error on MacOS / PHP Version 7.4.9 #290

Closed yogeshsaroya closed 4 years ago

yogeshsaroya commented 4 years ago

I am getting those error on MacOS / PHP 7.4.9 , same code working on Windows/CentOS

Notice: tempnam(): file created in the system's temporary directory in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 59

Notice: tempnam(): file created in the system's temporary directory in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 59

Warning: fopen(): Filename cannot be empty in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 902

Warning: str_repeat(): Second argument has to be greater than or equal to 0 in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 325

Notice: ZipArchive::addFile(): Empty string as filename in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 106

Notice: tempnam(): file created in the system's temporary directory in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 59

Warning: fopen(): Filename cannot be empty in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 902

Notice: ZipArchive::addFile(): Empty string as filename in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 109

Warning: ZipArchive::close(): Failure to create temporary file: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/PHP_XLSXWriter/xlsxwriter.class.php on line 114

yogeshsaroya commented 4 years ago

@mk-j Please help

mk-j commented 4 years ago

It looks like all the warnings and notices have to do with temporary files. It seems like your system is not configured to write those temporary files correctly. The first error, line 59 has to do with this function:

    protected function tempFilename()
    {
        $tempdir = !empty($this->tempdir) ? $this->tempdir : sys_get_temp_dir();
        $filename = tempnam($tempdir, "xlsx_writer_");
        $this->temp_files[] = $filename;
        return $filename;
    }

It just so happens you can set your own tempdir. You'll want to pick one that you have writeable privileges to, via $myXlsxPHPWriter->setTempDir("some/dir");