Страница 1 из 1

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

Добавлено: 2015.09.01, 10:40
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'
        ), 

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

Добавлено: 2015.09.01, 10:40
des1roer
нужно как-то autoload настроить?

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

Добавлено: 2015.09.01, 16:51
des1roer

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

Добавлено: 2015.09.02, 07:12
des1roer
up

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

Добавлено: 2015.09.08, 08:26
des1roer