PHPExcel_Writer_Exception with message “Could not close zip file php://output.”

后端 未结 12 753
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 00:30

I\'m using PHPExcel to export some data to user in an excel file. I would like the script to send the excel file to the user immediately after it\'s creation. Here is my tes

12条回答
  •  心在旅途
    2020-12-05 00:58

    Excelent Friend Work for me in php 7.1.2 and work in PhpSpreadsheet, fix the same file.

    PhpSpreadsheet/Writer/Excel2007.php
    

    the solution is in de function save in Excel2007.php

    if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
        $pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
    

    Replace the second line with this:

    $pFilename = dirname(__FILE__).'/'. rand(0, getrandmax()) . rand(0, getrandmax()) . ".phpxltmp";
    

    thanks.

提交回复
热议问题