How to speed up export to Excel

Topics: Developer Forum, User Forum
Mar 30, 2011 at 9:48 PM

Hello,

In my project I export over 3000 lines of text data into several pages (~10) . It takes time. Big time.

In my code I do like this:

Create worksheet A; fill in worksheet A; create worksheet B; fill in worksheet B; ..... save document in Excel5 format.

How could I speed up my export?

Apr 29, 2011 at 7:32 PM

I also I have the same problem

 

please help

Coordinator
Apr 29, 2011 at 8:51 PM

Without knowing a lot more detail about the structure of your code, it's almost impossible to answer this. There has been a lot written on this forum about performance such as this thread, or this one.

Use fromArray() where possible, rather than setting values for individual cells; when setting styles, use applyFromArray(), and set styles for a range of cells rather than for each individual cell; make use of the fluent interface; set setPreCalculateFormulas(false) when saving; etc.

May 23, 2011 at 10:21 PM

ok is very fast  fromArray()

 

have any examples use applyFromArray(),

May 24, 2011 at 1:06 PM

There are some examples in the PHPExcel developer documentation.doc at 4.6.18. Formatting cells (near page 21).

Nov 27, 2011 at 2:26 PM
Edited Nov 27, 2011 at 2:27 PM
MarkBaker wrote:

Without knowing a lot more detail about the structure of your code, it's almost impossible to answer this. There has been a lot written on this forum about performance such as this thread, or this one.

Use fromArray() where possible, rather than setting values for individual cells; when setting styles, use applyFromArray(), and set styles for a range of cells rather than for each individual cell; make use of the fluent interface; set setPreCalculateFormulas(false) when saving; etc.

After some code update and replacing cache instructions by

ini_set("memory_limit","256M");
ini_set("max_execution_time","0");

I do export in just 10-12 seconds (to build 1.5Mb Excel5 file). It is much much better than it was at the beginning.

After that I tried to switch to fromArray() to gain performance but got nothing.