One of the two methods I know about exporting PHP EXCEL files is: 1. when a user clicks export, PHP sends an EXCEL file header and outputs the content, in this way, the user can save it locally. However, this method currently does not meet my needs, because when the data exported by the user is too large, it fails because of the PHP memory limit .. Therefore, considering the use of paging, we can solve a question about exporting EXCEL from PHP.
The two methods I know are:
1. when you click Export, PHP sends an EXCEL file header and outputs the content so that the user can save it locally. However, this method currently does not meet my needs, because when the data exported by the user is too large, it fails because of the PHP memory limit .. So considering the use of paging, Method 2
2. access data by page, create a file, and insert data one by one. However, the file is saved on the server ..
This is just what I initially realized. I don't know how to solve it. I hope you will not smile .. Please advise ..
------ Solution --------------------
The size of the exported file. The memory limit is exceeded. How about increasing the memory limit?
You cannot try PHPEXCEL.
------ Solution --------------------
How big is the file! You can set the memory limit on the single page! In addition, you can release unnecessary variable memory in the file. if a page request needs to process 20 SQL queries, each SQL query returns 10 SQL results, if a row has 10 K, the page will be increased to 10 K * 10*20 = 2 m array allocation at the end of processing. this is not the case that sometimes we need to copy the most array, so optimize the code. The memory should be enough!
------ Solution --------------------
Don't read execl into the memory, and read a little bit.
------ Solution --------------------
Readfile. try it.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service