YII 结合 PHPExcel 使用问题

主要是两者都有autoloader,如果直接使用

会提示找不到YII的所有class

最后找到了一中优雅的解决办法:

http://www.yiiframework.com/forum/index.php/topic/18119-extensioneexcelview/page__st__20

 1 spl_autoload_unregister(array('YiiBase','autoload'));    
 2 try {
 3         Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true);
 4 }
 5 catch (Exception $e) {
 6         spl_autoload_register(array('YiiBase','autoload'));
 7         throw  $e;
 8 }
 9 $this->objPHPExcel = new PHPExcel();
10 spl_autoload_register(array('YiiBase','autoload'));

 

通过try{}catch{} 来决定使用哪个autoload

此外,发布到虚拟主机上还碰到了“ exception 'Exception' with message 'Could not close zip”的错误提示,问题原因:

http://phpexcel.codeplex.com/discussions/247239/

Generally this means one of 3 things:

The directory where you're trying to save the file doesn't exist
The directory/file has permissions that preclude you from writing to it
The file is already open in some other application, or has a lock on it

1.要保存到的文件目录不存在

2.没有写权限

3.文件被其它程序占用了

posted @ 2012-07-25 11:26  handt  阅读(357)  评论(0)    收藏  举报