I’ve implemented the wrapper extension for for eexcelview here:http://www.yiiframework.com/extension/toexcel/ to export my cgridview data. However, at this very time, I can only figure out how to export all the records for an entire model.
This is my action in the model’s controller
public function actionExcel()
{
// Load data (scoped)
$model = PackagingMetric::model()->findAll();
$fileName = 'Packaging_Metric_Data_Export_'. date("m-d-y");
// Export it
$this->toExcel($model,
array(
//'id',
'date',
'room',
'lot',
'country',
'total_labor_hours',
'total_run_time',
'std_rate',
'rate_syr_mh',
),
$fileName,
array(
'creator' => 'Data Access Portal',
),
'Excel2007'
);
}
The comments on the page for the extension explain to use a method similar to this to achieve this feature. However, I cannot seem to get this to work.
$model = YourModel('search');
$model->type = 1; // This will filter out all the results whose type is 1
$dataProvider = $model->search();
Could anyone clarify how to retrieve the filtered cgridview results to be exported by the extension?
if I set
$model= $model->search()
I only get the default first page of records from cgridview exported to the csv