1. Occurrence scenario
- In
thinkphp
framework usingphpoffice/phpexcel
, exporting Excel tables directly to the browser for download, the error is reported: ERR_INVALID_RESPONSE - Note: The export is fine in the local windows environment, but the problem only occurs in the online Linux environment.
- Screenshot of the problem.
2. Find a solution
1. Online solutions
1) Buffer problem
calling ob_clean() before calling save(“ php://output ")
, part of the code is as follows:
ob_clean(); //Emptying the cache
// final output via browser
$fn = "The name of the file (" . date("Y.m.d") . ").xls"; // the name of the file to be saved
header('Content-Type: application/vnd.ms-excel; charset=utf-8');
header("Content-Disposition: attachment;filename={$fn}");
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
2) Error is reported in line 581 of factory581, and break is deleted
Error in factory581 line, delete break;
PHPExcel\Calculation\Functions.php file, remove break at line 581
our phoffice/phpexcel is installed by composer. We have to change the source code every time we update it. It is not recommended to modify the source code. Even if it can solve the problem, it will not be adopted
2. My solution to this problem is to install the zip extension under Linux
[solution] my problem is that Linux lacks the zip
extension. You can install it~
3. Zip extension
PHP under windows (my version is 7.3.3) has its own zip extension, and there is no directory_zip.dll
file under the php/ext
path, as shown in the figure
PHP under Linux does not have zip extension installed
Read More:
- Mac PHP Fatal error: Class ‘Memcache’ not found
- PHP error in Windows: class’ mysqli ‘not found
- [Solved] PHP Fatal error: Uncaught Error: Class ‘Redis‘ not found in
- PHP encryption 3DES error Call to undefined function: mcrypt_module_open() solution
- [Solved] Fatal error: Uncaught Error: Class ‘Imagick‘ not found
- composer Error: The requested PHP extension ext-bcmath * is missing from your system. Install or enable
- [Solved] has been blocked by CORS policy: Response to preflight request doesn‘t pass access control check: No
- ThinkPHP interface cross domain request error [Solved]
- [Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()
- How to solve Magento 500 internal server errors
- Error during session start; please check your PHP and/or webserver log file and configure your PHP
- [PHP] php8 jit does not support 32-bit systems WARNING: JIT not supported by host architecture
- [Solved] PHP post Datas json_decode Error: 4 JSON_ERROR_SYNTAX
- PHP use __Sleep() and __wakeup() method serializes the object
- [Solved] Error while sending STMT_PREPARE packet. PID=29294
- [Solved] Warning: Unknown: Failed to write session data using user defined save handler. (session.save_path:
- PHP solves the problem that composer exceeds the memory size Allowed memory size
- PHP: How to parse MHT file into HTML
- [Solved] OpenSSL Error messages: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure
- Lack of files in composer installation [How to Solve]