Converting single sheet in an XLS file to CSV with PHPExcel - Memory exhausted

后端 未结 1 1375
闹比i
闹比i 2021-01-20 05:13

I\'ve got an Excel file (97-2003) which I need to be able to import via PHP and have it convert just one sheet in the file to CSV. These are uploaded by users so there\'s no

相关标签:
1条回答
  • 2021-01-20 05:42

    PHPExcel 1.7.3 introduced cell caching as a mechanism to reduce the memory usage of maintaining large workbooks within the limits of PHP memory. Cell caching offers a trade-off reducing memory usage either by serializing the cell data to reduce its size, or allowing cell data to be held outside of PHP memory with only an index of cells maintained "in memory"; but at a cost in performance.

    By default, cell caching will store all cells in memory for the best speed; but other caching options include:

    • zipped in memory
    • serialized in memory
    • igbinary serialized in memory
    • red on disk
    • APC
    • memcache
    • wincache
    • phptemp
    • sqlite or sqlite3 database

    speed and memory usage vary between them and will also vary depending on operating platform and other setings, so you'd need to work out which was the best option to use in your own situation; but as a general guideline, the more efficient the use of memory, the slower performance. The SQLite options were the most recently added, and provide the best memory usage because even the "cell index" isn't maintained in memory, and I'm currently testing some changes to see if I can improve the sqlite execution speed.

    Usage is covered in section 4.2.1 of the developer documentation

    0 讨论(0)
提交回复
热议问题