Recently, i have find an issue to export CGridview filtered record in excel in my Yii application. I have searching out lot many thigs but i did not get exact solution which i want. In all reference tutorial, i can export CGridview record without filtered or shorted record.
Finally i got one solution to export filtered CGridview record to excel using session and toexcel extension of Yii. You can see in following search method, I have stored filtered record in session variable and return it. So whenever i will search any record details it will store in session variable. And later, i will use that session variable to export action.
public function search()
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$nationality_data = new CActiveDataProvider(get_class($this), array(
$_SESSION['nationality_records'] = $nationality_data;
Here, Assign CActiveDataProvider data to session variable.
public function actionNationalityExportToExcel()
'creator' => 'RudraSoftech',
Note : Also go throw the toexcel extension and put require class file in extension folder directory.
Using this extension you can export data in excel in multiple excel version format like 2005 and 2007.
Page 1 of 1
Export To Excel Cgridview Filtered/shorted Record In Yii.
Share this topic:
Page 1 of 1