In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to solve the problem of exporting PHP7 to Excel newspaper ERR_EMPTY_RESPONSE". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "PHP7 export Excel newspaper ERR_EMPTY_RESPONSE how to solve it"!
An error page is displayed when using the exported Excel. At this time, it is found that the uploaded Excel can read the data normally, but not when exporting.
The version of PHP I use here is 7.1. The PHPExcel version uses 1.8.1. Github address:
Https://github.com/PHPOffice/PHPExcel/tree/1.8.1 . You can see that the author has not updated for 3 years.
Copy all the Class contents in PHPExcel to the vendor directory of thinkphp. Rename to PHPExcel. That is, replace the old plug-in with this 1.8.1 version.
I won't say exactly how to write Excel and introduce plug-ins. Tell me about the writing of the code.
The problem actually focuses on the Excel output. (the following is the way to successfully export Excel, and the previous part of generating Excel is omitted.) define the header and output it directly.
$filename = "template file" .date ("YmdHis"). Rand (1000 9999); $filename = iconv ("utf-8", "gb2312", $filename); header ("Pragma: public"); header ("Expires: 0"); header ("Cache-Control:must-revalidate, post-check=0, pre-check=0"); header ("Content-Type:application/force-download"); header ("Content-Type:application/vnd.ms-execl"); header ("Content-Type:application/octet-stream") Header ("Content-Type:application/download");; header ('Content-Disposition:attachment;filename='.$filename.'.xls'); header ("Content-Transfer-Encoding:binary"); $objWriter- > save (' php://output')
You can also use PhpSpreadsheet to read and write Excel.
Github: https://github.com/PHPOffice/PhpSpreadsheet
Documentation: https://phpspreadsheet.readthedocs.io/en/develop/
At this point, I believe you have a deeper understanding of "how to solve the problem of PHP7 exporting Excel newspaper ERR_EMPTY_RESPONSE". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.