Reading multiple files with PHPExcel
        Posted  
        
            by KaOSoFt
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by KaOSoFt
        
        
        
        Published on 2010-04-23T17:57:21Z
        Indexed on 
            2010/04/23
            18:43 UTC
        
        
        Read the original article
        Hit count: 497
        
Hello there.
I just recently started using this library (the one from CodePlex), but I ran into some issues. My goal is to use it so I can process some data from multiple Excel files, and send such data to a database, per file. I'm doing something like:
foreach( $file_list as $file ) {
    $book = PHPExcel_IOFactory::load( $path . $file );
}
So, inside the foreach I'm (for now) just showing the data to the user, but after five files, I get a memory error:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 50688 bytes) in /var/www/test/classes/PHPExcel/Shared/OLERead.php on line 76
Is there a way to __destruct the object after each file is loaded, so space is reserved (made free) for the next file, instead of accumulating it, or do you rather know of a reason and work-around for this?
Please let me know any suggestions you have.
Thanks in advance.
© Stack Overflow or respective owner