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
Post a Comment