Как сделать выгрузку в excel

Общие вопросы по использованию фреймворка. Если не знаете как что-то сделать и это про Yii, вам сюда.
Ответить
Аватара пользователя
des1roer
Сообщения: 391
Зарегистрирован: 2015.02.06, 17:03
Контактная информация:

Как сделать выгрузку в excel

Сообщение des1roer »

пробую установить вендором phpexcel

Код: Выделить всё

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 "phpoffic
e/phpexcel:@stable"

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'
        ), 
Аватара пользователя
des1roer
Сообщения: 391
Зарегистрирован: 2015.02.06, 17:03
Контактная информация:

Re: Как сделать выгрузку в excel

Сообщение des1roer »

нужно как-то autoload настроить?
Ответить