4

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.

4

2 回答 2

2

PHPExcel 的最新 SVN 代码(今天刚刚签入)引入了单元缓存以减少内存使用......这是一个新功能,我什至没有时间记录它。虽然默认方法与当前方法相同,但工作表 <--> 单元格关系包含循环引用,我相信使用任何减少内存的缓存机制都应该消除这种循环引用。如果没有,请告诉我,我应该能够在取消设置工作簿/工作表时使用一些缓存逻辑来中断引用,这些缓存逻辑在序列化单元格以进行缓存时已经禁用了此连接。

于 2010-04-23T20:26:21.320 回答
0

这个问题已经有一段时间了,而且看起来没有办法解决它——也就是说,除非有人在 5.3 发布后想出了一些聪明的东西......

“...看来 PHP 5.3 会解决这个问题。但是,我希望在某个地方看到对此的确认。” [2008 年 10 月 21 日]

来源)(更多的东西

于 2010-04-23T18:28:32.967 回答