Phpexcel generating large data volumes for Excel time-consuming issues

Source: Internet
Author: User
Phpexcel Generating Big Data volume Excel time-consuming problems
Recently in using Phpexcel to do a report template, the user data to do some processing, and then export Excel for customers to view.
Now we have some problems:
1. Time-consuming issues
Tested to generate a 10000-row, 6-column Excel with only one sheet, which takes a total of 26 seconds
I printed out the internal parts of the code, and found that the values and styles of the cells in the sheet were time consuming, and the two added up to 11 seconds;
Another is that saving to a local file saves (' Test.xls ', ' Excel5 ') time to take 15 seconds (don't know why it's so long).
Fill in the value of cell in sheet I use the FromArray method in Phpexcel, and the styling is done using Getcell ($cellRange),
Is there a way to optimize the point, can shorten the time?

2 Memory usage Issues
In the above case, my code uses the highest peak memory 103m, the amount of data at a large point that can not be imagined, my data are stored in the array,
Does it have anything to do with it? Do you have any good advice?

Please help, thank you first!

------Solution--------------------
The first question is not good.
The second question, you put 10,000 data in the array, when the program began to execute, a one-time bar data loaded into the memory, it will certainly consume a lot of memory, you can consider the data into the database, and then loop processing, or write files, with the pointer processing
------Solution--------------------
From array? That is, Sir, into a large array and insert it?

Isn't it possible to iterate through the inserts?

I've done it before. Export about 50 0000 data in Excel. It does take longer (more than 10 sheet, about 30s) and the memory footprint is scary. It is said that the new version of Phpexcel adds functionality to the cell cache, which may be useful for performance improvements.
------Solution--------------------
Why not write to CSV format?
  • Related Article

    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.