php - Populating excel using PHPExcel extension from Yii -


this code:

    $col =  array("year", "month");     $result = yii::app()->db->createcommand("select * mytable `column` = '".$cnp."' ")->queryall();     $dataprovider = new carraydataprovider($result, array());     $excelgenerator = new excelview(array('dataprovider' => $dataprovider,        'columns' => array(               array(                 'header' => 'year',                 'value' => '$data->year',             ),             array(                 'header' => 'month',                 'value' => '$data->month',             ),         ),             ));    $excelgenerator->run(); 

the result of excel file 2 column name year , month, how can populate data taken select ? select returns multiple results. thx

since using carraydataprovider, value should accessed array:

'value' => '$data["month"]', 

you can use cgridview shorthand columns structure

'columns' => array(     'year',     'month::month of year',     'other_column:type:other column', 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -