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:
- How to solve Magento 500 internal server errors
- How to Solve PHP Error: no package’oniguruma’ found
- How to Solve opcache error: zend_mm_heap corrupted
- [Solved] has been blocked by CORS policy: Response to preflight request doesn‘t pass access control check: No
- How to Solve PHP Fatal error: Namespace declaration statement has to be the very first statement
- composer Failed to decode response: zlib_decode(): data error
- [PHP] Solve PHP Call to undefined function ldap_connect()
- PHP: How to parse MHT file into HTML
- [Solved] PhpSpreadsheet Error: Invalid cell coordinate [1
- How to Hide index.php
- Hyperf [ERROR] Invalid protocol of registry consul[205]
- php_network_getaddresses: getaddrinfo failed (How to Fix)
- Using $this when not in object context in (How to Fix)
- Leetcode 357: How to calculate the number of digits with different digits
- [PHP] Solve Call-time pass-by-reference has been removed
- PHP: How to get the total number of data in the MySQL table (total number of rows)
- [PHP] Solve the problem that the new version of Chrome’s same-site policy cannot record cookies across domains
- [PHP] Solve the limitation of uploading files in nginx php 413 Request Entity Too Large
- [PHP] Solve the 500 error problem-nginx and fpm have no error logs
- [Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()