insertNewBeforeRow profiling

Topics: Developer Forum, User Forum
Jun 1, 2012 at 7:27 AM


I'm using PHP 5.3.10 and PHPExcel 1.7.7.

PHPExcel_ReferenceHelper->insertNewBefore() seems to be a really expensive operation.  I've have a profile (using XDebug) where it is only called 42 times, yet it is 21% of the total running time, (49,110ms out of a total of 231,279ms, with an average call time of 1,169ms).

Are there any performance tips, besides calling it less (though that is something I'm going to be trying next)?



Reuben Helms


Jun 4, 2012 at 6:09 AM

It would seem the short answer is to not insert rows, if you can do so.

If you can't avoid it, have as little data as possible between the inserted row and the end of the worksheet, to avoid having to update all the references.  And if you can do a pre calculation, insert the rows in bulk with as few individual statements as possible.

Jun 4, 2012 at 10:43 AM

To confirm the comments you've made, it is best to avoid inserting rows or columns because every cell reference below or after the point of insertion needs shuffling, and it is also necessary to check if any other cells reference in formulae those that are being moved by the insert... even if there are no updates required, PHPExcel is not aware of this until it executes that check. This does make it an expensive operation