/** * export csv des echantillons. */ public function actionExportCsv() { set_time_limit(60); $model = new Echantillon('search'); $model->unsetAttributes(); $criteria = $_SESSION['criteria']; $criteria->limit = 30000; if (isset($_GET['Echantillon'])) { $model->attributes = $_GET['Echantillon']; } $dataProvider = new CActiveDataProvider('Echantillon', array('criteria' => $criteria, 'pagination' => false)); $filename = 'samples_list.csv'; $csv = new ECSVExport($dataProvider); $toExclude = array(); $toExport = $model->attributeExportedLabels(); foreach ($model->attributeLabels() as $attribute => $value) { if (!isset($toExport[$attribute])) { $toExclude[] = $attribute; } } $csv->setHeaders($toExport); $csv->setExclude($toExclude); // $csv->exportCurrentPageOnly (); Yii::app()->getRequest()->sendFile($filename, $csv->toCSV(), "text/csv", false); }