2 回答

TA貢獻1877條經驗 獲得超6個贊
我使用EExcelview擴展,非常有用。
下載并提取代碼/protected/extensions/
將其添加到您的文件中,如下所示/protected/config/main.php
'import' => array(
'app.models.*',
'app.portlets.*',
'app.components.*',
'app.extensions.*',
...
'ext.phpexcel.*', # here we are importing the extension
),
在要下載 CSV 文件的視圖中添加并優化代碼,如下所示:
$this->widget('EExcelView', array(
'dataProvider' => $model->search(),
'creator' => Yii::app()->name,
'grid_mode' => 'grid',
'title' => 'CSV File title',
'subject' => 'CSV File Subject',
'description' => 'CSV File Description',
'exportText' => 'Download file ',
'filename' => urlencode('My file to download'),
'exportType' => 'CSV', # Available Options => Excel5, Excel2007, PDF, HTML, CSV
'template' => "{exportbuttons}",
'columns' => array(
'colA',
'colB'
...
),
));
- 2 回答
- 0 關注
- 131 瀏覽
添加回答
舉報