Hello there!
I’m trying to get a simple Excel output from a view/model/admin filtered query.
I have put on _search.php an additional button:
echo CHtml::submitButton( 'Export to Excel', array( 'name' => 'export' ) );
So I’m trying to catch it on controller actionAdmin():
public function actionAdmin()
{
$model = new Invoice('search');
$model->unsetAttributes();
if( isset( $_GET['Invoice'] ) )
$model->attributes = $_GET['Invoice'];
if( isset( $_GET[ 'export' ] ) )
{
header( "Content-Type: application/vnd.ms-excel; charset=utf-8" );
header( "Content-Disposition: inline; filename=\"test.xls\"" );
$dataProvider = $model->search();
$dataProvider->pagination = False;
foreach( $dataProvider->data as $data )
echo $data->class, "\t", $data->branch, "\t", $data->number, "\t", $data->total, "\n";
Yii::app()->end();
}
$this->render('admin',array(
'model'=>$model,
));
}
The problem seems to be at [font=“Courier New”]if( isset( $_GET[ ‘export’ ] ) )[/font] 'cos it never download when you press the Export submit button… or I’m troubling with an ajax subjacent request from search-form?
Thanks for any clue,
cbi