как можно подключить phpexcel и при клике отдавать документ с содержимым из запроса\массива? вот что пока сделал пробую установить вендором phpexcel d:\open\openserver>cd D:\open\OpenServer\domains\localhost\mining\protected D:\open\OpenServer\domains\localhost\mining\protected>composer require "yiisoft/yiistable" D:\open\OpenServer\domains\localhost\mining\protected>composer require "phpoffice/phpexcelstable" D:\open\OpenServer\domains\localhost\mining\protected>composer require laxu/yii-phpexcel отсюда https://github.com/laxu/yii-phpexcel но при $model->writeExcelFile(); //\analiz\views\element\admin.php public function writeExcelFile() //\analiz\models\Element.php { $manager = Yii::app()->getComponent('yii-phpexcel'); //Create empty instance $excel = $manager->create(); //Add a header row with a grey background $headerStyle = array( 'fill' => array( 'type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'CCCCCC') ) ); $excel->addHeaderRow( array( 'header1', 'header2', 'header3' ), $headerStyle ); //Add a few rows of data to the document //Note that addData doesn't care about the actual keys in the data, only the order of values $data = array( array( 'data1', 'data2', 'data3', ), array( 'id' => 1, 'name' => 'Example', 'moreData' => 'Something' ) ); $excel->addData($data); $excel->save(); } получаю CException Неправильный алиас "laxu.yii_phpexcel". Убедитесь, что он указывает на существующую директорию или файл. \protected\config\main.php // application components 'components' => array( 'yii-phpexcel' => array( 'class' => '\laxu\yii_phpexcel\ExcelManager', 'savePath' => 'app.files.excel' ), как понимаю нужно хитро autoloader настроить, не пойму как
Устанавливали comoser-ом или сами? Все конфиги настроили? Я с yii1 правда не работал почти, не знаю, как там автозагрузчик сделан.
через композер. Код (Text): d:\open\openserver>cd D:\open\OpenServer\domains\localhost\mining\protected D:\open\OpenServer\domains\localhost\mining\protected>composer require "yiisoft/yii:@stable" D:\open\OpenServer\domains\localhost\mining\protected>composer require "phpoffice/phpexcel:@stable" D:\open\OpenServer\domains\localhost\mining\protected>composer require laxu/yii-phpexcel только толку мало. Код (Text): public function actionExcel() { // unregister Yii's autoloader spl_autoload_unregister(array('YiiBase', 'autoload')); // register PHPExcel's autoloader ... PHPExcel.php will do it $phpExcelPath = Yii::getPathOfAlias('ext.phpexcel'); include($phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php'); // register Yii's autoloader again spl_autoload_register(array('YiiBase', 'autoload')); // This requires Yii's autoloader $models = SomeModel::model()->findAll(); // This requires PHPExcel's autoloader $objReader = PHPExcel_IOFactory::createReader('Excel5'); } получаю Fatal error: Class 'CExceptionEvent' not found in D:\open\OpenServer\domains\localhost\yii\framework\base\CApplication.php on line 734 Fatal error: Class 'CException' not found in D:\open\OpenServer\domains\localhost\yii\framework\web\CThemeManager.php on line 110 такое ощущение что он обратно его подключить не может