doumaojin4008 2014-01-21 07:33
浏览 99
已采纳

使用Yii自动加载PHPExcel库(包含(PHPExcel_Worksheet_Drawing.php):无法打开流:没有这样的文件或目录)

I'm using Yii framework , and I have to load PHPExcel classes.

in my main.php I set the configuration as

'import'=>array(
        'application.models.*',
        'application.components.*',
                'application.extensions.*',
                'ext.PHPExcel.PHPExcel',            
    ),

in I was edit the Register function inside Autoloader.php as follow

public static function Register() {
        $functions = spl_autoload_functions();

          foreach($functions as $function)
            spl_autoload_unregister($function);
          $functions=array_merge(array(array('PHPExcel_Autoloader', 'Load')), $functions);

          foreach($functions as $function)
            $x = spl_autoload_register($function);
          return $x;
  }

when I call $objPHPExcel =new PHPExcel(); it's working well,

but when I call $objDrawing = new PHPExcel_Worksheet_Drawing(); its return

include(PHPExcel_Worksheet_Drawing.php): failed to open stream: No such file or directory

my directory structure is :

extensions
    -----PHPExcel
          -------PHPExcel
    ------ PHPExcel.php

Thanks for help

  • 写回答

1条回答 默认 最新

  • doutang1992 2014-01-21 08:26
    关注

    Try this code out if it works, notice there are dual *

    Yii::import('ext.PHPExcel.**', true); 
    
    $objDrawing = new PHPExcel_Worksheet_Drawing();
    var_dump($objDrawing);
    

    [Tested in Yii version: 1.1.13]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?