学习使用PHPExcel
php框架:thinkPHP3.2.3
excel工具:PHPExcel 1.8
===========================
关于 phpExcel 的下载:
https://github.com/PHPOffice/PHPExcel
============================
自我总结&实战:
==============================
1、将 PHPExcel 放到 tp 框架下的 vendor 目录下

2、thinkphp3.2.3 的引入外部文件的方式
vendor("phpExcel.Classes.PHPExcel");
$objPHPExcel = new \PHPExcel(); // new 调用的时候,前面加 “\”
=》关于 vendor 的使用部分,最好看官方手册!
http://document.thinkphp.cn/manual_3_2.html#autoload
3、使用 PHPExcel 1.8 读取 Execl 表的数据,并插入到mysql数据库
=》正在尝试,稍后记录正确的使用方法!
=========================================
报告错误:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) i
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes) in E:\git\tp323\haodiu\ThinkPHP\Library\Vendor\phpExcel\Classes\PHPExcel\Worksheet.php on line 1213
修改php.ini配置文件:
memory_limit = 512M
=》但是治标不治本,仍旧太慢,参考文献,对PHPExcel进行调整:
http://www.01happy.com/phpexcel-read-big-excel-file/
http://www.cnblogs.com/anniu1122/p/6593522.html
=》结合上面的文章,可以很好地解决问题!

浙公网安备 33010602011771号