Cgridview Doesnt Export Using Phpexcel

Good day guys please help me with my problem I have here a situation that will export a filtered data to excel but when i clicked the button it doesnt export but when i tried delete the export code to alert the data to check if the data was successfully posted it alerted back upon successful.

This is the button that will post the date range to be filtered

echo(CHtml::link('Export to Excel', "",


			'style'=>'cursor: pointer;',





        	function catchData(){

			var fdate = $('#dufrom').val();

			var ldate = $('#duto').val();


				type: 'POST',

				data: {fdate : fdate, ldate : ldate},

				url: '<?php echo CController::createUrl('dutyReport/export'); ?>',	

				//success: function(data){ alert(data); }




this is the controller that will export the filtered date range to excel

public function actionExport()


		$fdate = $_POST['fdate'];

		$ldate = $_POST['ldate'];

		echo $fdate,$ldate;

		// Load data (scoped)

		$criteria = new CDbCriteria;

		$criteria->condition = 'duty_date BETWEEN '.$fdate.' AND '.$ldate;



		// Export it










		'Duty Report',


			'creator' => 'Jimuel',





why not using Extensions?

See here and this one specifically

Hi Jimuel,

What do you do in toExcel() method? Creating and saving an excel file in the server side? Or, directly returning the output content?

And what is the expected scenario when the user clicks on ‘Export to Excel’ link? Does he/she get prompted to download the created excel file?

I think you’d be better use a normal link or post instead of an ajax call.

tnx for the reply well for the export to excel method there is a cgridview displayed in the page and then when the button was clicked it will download an excel file. when i use a normal link or post the first and last date doesnt pass to the controller in order to filter the data to export to excel.

i already used an extension but i will try different extension tnx for your advise.