求解关于PHP导出EXCEL的一个疑义

WBOY
Release: 2016-06-13 13:26:35
Original
787 people have browsed it

求解关于PHP导出EXCEL的一个疑问

我所知道的两种办法是

1、用户点击导出的时候,PHP发送EXCEL类型文件头,输出内容,这样用户就可以保存到本地。但这个办法目前满足不了我的需求,因为当用户导出的数据过大时,因为PHP内存的限制而失败。。所以考虑到使用分页处理,方法2

2、使用分页访问数据,创建文件,逐条插入,但这种方法的话,文件会保存在服务器里。。

这只是我初步认识到的,不知道有什么方法可以解决,望大侠们不要见笑。。求指教。。

------解决方案--------------------
你导出的文件有多大。会超出内存限制。把内存限制改大点呢?

试试 PHPEXCEL 这个类看行不行。
------解决方案--------------------
文件会有多大呀!可以在单页面设置一下内存限制呀!再者你可以把文件中不用的变量内存给释放掉,如果一个页面请求要处理20个sql查询,每个sql查询返回10个sql结果,如果一条row有10K, 那么这个页面到处理结束时就要增加到 10K*10*20=2M的数组分配,这还不算有时候我们需要最数组进行复制,所以优化一下代码。内存应该是足够了!
------解决方案--------------------
别一下把execl读到内存里, 读一点发一点。
------解决方案--------------------
readfile,试一下好不好用。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!