Custom SQL Query To Excel In Yii1.0

Please read this tutorial before to follow this post.

This tutorial will help you to create a excel sheet using custom sql query.

In Model Code

public function searchbydocumentdetails(){
		return new CSqlDataProvider($query,

In Controller Code

public function customsqltoexcel(){
	$document=new Document;
		array('DocuemntName', 'CategoryName', 'DownloadCredits', 'UploadCredits', 'Downloadimits', 'Count', 'Status'),
		'Document Reports',
		array( 'creator' => 'Sourcecode',   ),
		'Excel2007'// This is the default value, so you can omit it. You can export to CSV, PDF or HTML too

Leave a Reply

Your email address will not be published. Required fields are marked *