Problems related to time-consuming excel when phpexcel generates large data volumes

Source: Internet
Author: User
Phpexcel generates a large amount of data. the time used in excel is recently used to create a report template, process user data, and export the excel file for the customer to view. Now I have encountered some problems: 1. A 10000-row and 6-column excel file containing only one sheet is generated after testing, it took more than 26 seconds in total. I printed out all parts of the code, and phpexcel generated a large amount of data.
Recently, phpexcel was used as a report template to process user data and export excel for customers to view.
Now we have encountered some problems:
1. time consumption problems
After testing, it takes more than 26 seconds to generate an excel file with 10000 rows and 6 columns containing only one sheet.
I printed the time consumption of each part of the code and found that it took 11 seconds to fill the cell value and style in the sheet;
It also takes 15 seconds to save the save('test.xls ', 'excel5' in the saved file (I don't know why it is so long ).
Fill in the cell value in sheet. I use the fromArray method in phpexcel and set the style using getCell ($ cellRange,
Is there a way to optimize the point, can you shorten the time?

2 Memory usage problems
In the above situation, the maximum memory usage of my code is 103 MB, and the data size is too large to be imagined. my data is saved in an array,
Is it related to this? Are you recommended?

Please help. thank you!

------ Solution --------------------
The first question is hard to say
The second problem is that you put 10 thousand pieces of data in the array. when the program starts to execute, load all the data into the memory at a time, which will definitely consume a lot of memory, you can consider writing data into the database, and then process it cyclically, or write it into a file, and use a pointer for processing.
------ Solution --------------------
From array? That is, is it possible to insert a large array?

Can it be inserted cyclically?

I have previously used an excel file to export about 50 million pieces of data. it does take a long time (more than 10 sheets, about 30 s), and the memory usage is terrible. It is said that the new phpexcel version has added the cell cache function, which may help improve performance.
------ Solution --------------------
It is better to write data in csv format.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.