Free Memory

Topics: User Forum
Aug 16, 2012 at 8:40 PM

Hi all,

i'm wondering if is there a way to disconnect single worksheet while walking file content to save memory.

I mean, if i have to parse several excel files, every file parsing can be closed by a simple

     $objPHPExcel->disconnectWorksheets();
     unset($objPHPExcel);

that disonnects worksheets from the object and unsets the object. This allows the script to run on many files without using Terabytes of memory :)

my problem is if INSIDE a single file i've ENORMOUS worksheet. In this case, as you can understand, disconnecting worksheets at the end of parsing is a nonsense, but as far as i know there is not a way to disconnect a SINGLE worksheet while parsing a file

am i wrong?

thanks

bye

Coordinator
Aug 16, 2012 at 9:18 PM

If you look at the actual code for disconnectWorksheets(), you'll see that it loops through each worksheet in the workbook, and executes disconnectCells() against that sheet. You can then remove that sheet cleanly.

Coordinator
Aug 17, 2012 at 12:17 AM

Your other option, though it may not be practical, is loading only one worksheet at a time, processing that, then disconnect/unset and load the next worksheet.

Aug 17, 2012 at 11:46 AM

very nice, i'll think to "disconnectCells", i didn't look into source code, it's the price of my heavy bottom :)

Thank you Mark