generate excel

hi all,

Can anybody tell me how to generate an excel onclick of a button. I have gone through the documentation phpexcel but i dont know how to implement it. Can anybody show me an example.


This is solved. I figured out how to use it.

Just had to insert this code in the controller

public function actionGenerate()


		$model=new Purchases;

$data = array(

    1 => array ('Name', 'Surname'),

    array('Schwarz', 'Oliver'),

    array('Test', 'Peter')



$xls = new JPhpExcel('UTF-8', false, 'My Test Sheet');







Or you can create widget :)

HI qwerty,

The excel file that i generated is corrupt. Can u tell me how to fix this?



how and where we do create widget

maybe this discussion will help -

Hi mithila, i’m interested with yr topic cause i faced the same thing…

this’ my problem. I’d like to export my table (gotten from sql) into excel format. but i really have a doubt with it… Do you have any suggestion for me? A lot of thanks :D

you can try the code generated by my extension giiplus CRUD generator:

Hi Sirin,

I want to use your extension, but the additional 3 features are never generated.

I’ve copied the into extension directory & I use Yii bootstrap.

Here’s my gii Module config:








and the following is my component’s config:







What is missing from my system configuration?

Thank you Sirin!