Possible Duplicate:
Alternative for PHP_excel
PHPExcel reader — help required可能的重复:PHP_excel PHPExcel阅读器的替代-需要帮助
First post. I have a very specific need for reading and writing very large (5mb+) excel files using PHP/My SQL. I have used PHPExcel and, while it is very elegant, it is way too slow and uses far too much PHP memory for my needs. At the moment I am limited to 32M PHP memory from my host.
第一篇文章。我特别需要使用PHP/My SQL读取和编写非常大(5mb+)的excel文件。我使用了PHPExcel,虽然它很优雅,但是它太慢了,而且使用了太多PHP内存来满足我的需要。目前,我的主机上的PHP内存限制为32M。
My current solution is as follows:
我目前的解决方案如下:
Importing to database
导入到数据库
I use php-excel reader (http://code.google.com/p/php-excel-reader/) for .xls files - Can import about 3000 rows before PHP runs out of memory.
I use spreadsheet reader (https://github.com/nuovo/spreadsheet-reader) for .xlsx files and so far I've tried 5000 rows+ without running out of memory. It is very slow which leads me to believe it is opening and closing the excel file and reading chunks of data at a time.
Exporting
对于.xls文件,我使用PHP -excel reader (http://code.google.com/p/php-excel-reader/)——可以在PHP耗尽内存之前导入大约3000行。我对.xlsx文件使用电子表格阅读器(https://github.com/nuovo/spreadsheet-reader),到目前为止,我已经尝试了5000行+,但没有耗尽内存。它的速度非常慢,这让我相信它每次都在打开和关闭excel文件并读取数据块。出口
PHP Excel for anything under about 500 rows. Works beautifully but is very slow and can't handle for than a few hundred rows with 32Mb PHP memory (Note: I am using cacheing which has helped but not enough)
PHP Excel适用于500行以下的任何内容。它工作得很好,但是非常慢,并且不能处理超过几百行、32Mb的PHP内存(注意:我正在使用缓存,这有帮助,但还不够)
Basic tab-delimited text for any more than 500 rows. Very fast, no limit on rows but no formatting and not true excel.
对于任何超过500行的基本的用表分隔的文本。非常快,没有行限制,没有格式,也没有真正的excel。
Ideally, I'm looking for an all-in-one solution that can read and write .xls and .xlsx files quickly and without running into memory issues. I don't mind a commercial product and would be happy to pay a few hundred dollars for something that works.
理想情况下,我正在寻找一种可以快速读写.xls和.xlsx文件的一体式解决方案,并且不会遇到内存问题。我不介意一个商业产品,我很乐意花几百美元买一个有用的东西。
I have spent hours scouring the internet and this site but haven't found anything yet.
我花了几个小时搜索互联网和这个网站,但还没有找到任何东西。
Any ideas?
什么好主意吗?
PS: If anyone wants to see how I've implemented the above solutions, I'd be happy to share the code
PS:如果有人想知道我是如何实现上述解决方案的,我很乐意分享这些代码
5 个解决方案
#1
4
As you're unhappy with the speed and memory requirements of PHPExcel, I'll point you to my standard answer to this question. If the answer isn't listed there, then it probably doesn't exist: that list is as comprehensive as I know.... though people writing their own alternatives to PHPExcel rarely bother to tell me making it difficult to keep up-to-date
当您对PHPExcel的速度和内存要求不满意时,我将向您指出我对这个问题的标准答案。如果答案没有上市,那么它可能不存在:列表是全面我知道....虽然写自己的PHPExcel替代品的人很少费心去告诉我要保持与时俱进。
#2
2
As far as my experiences go, excel implementations in php don't have a good performance (it took perl implementations 8 minutes to write what php was doing for 3 hours) so I end up using Perl.
就我的经验而言,php中的excel实现没有很好的性能(perl实现花了8分钟才写出php在做什么),所以我最终使用了perl。
The only think you can really do about problem with running out of memory is to set higher memory_limit
.
唯一能解决内存耗尽问题的方法是设置更高的memory_limit。
#3
0
For writing you might want to give a try to http://pear.php.net/package/Spreadsheet_Excel_Writer
对于写作,您可能想尝试一下http://pear.php.net/package/Spreadsheet_Excel_Writer。
#4
-1
I would recommend PHPExcel. It's easy to work with and easy to change functionality in if that would be needed. I have used it a lot and never had any issues, even with big complicated spreadsheets.
我建议PHPExcel。如果需要的话,很容易使用和更改功能。我经常使用它,从来没有遇到过任何问题,即使是大而复杂的电子表格。
#1
4
As you're unhappy with the speed and memory requirements of PHPExcel, I'll point you to my standard answer to this question. If the answer isn't listed there, then it probably doesn't exist: that list is as comprehensive as I know.... though people writing their own alternatives to PHPExcel rarely bother to tell me making it difficult to keep up-to-date
当您对PHPExcel的速度和内存要求不满意时,我将向您指出我对这个问题的标准答案。如果答案没有上市,那么它可能不存在:列表是全面我知道....虽然写自己的PHPExcel替代品的人很少费心去告诉我要保持与时俱进。
#2
2
As far as my experiences go, excel implementations in php don't have a good performance (it took perl implementations 8 minutes to write what php was doing for 3 hours) so I end up using Perl.
就我的经验而言,php中的excel实现没有很好的性能(perl实现花了8分钟才写出php在做什么),所以我最终使用了perl。
The only think you can really do about problem with running out of memory is to set higher memory_limit
.
唯一能解决内存耗尽问题的方法是设置更高的memory_limit。
#3
0
For writing you might want to give a try to http://pear.php.net/package/Spreadsheet_Excel_Writer
对于写作,您可能想尝试一下http://pear.php.net/package/Spreadsheet_Excel_Writer。
#4
-1
I would recommend PHPExcel. It's easy to work with and easy to change functionality in if that would be needed. I have used it a lot and never had any issues, even with big complicated spreadsheets.
我建议PHPExcel。如果需要的话,很容易使用和更改功能。我经常使用它,从来没有遇到过任何问题,即使是大而复杂的电子表格。