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.

Thankyou

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')

);

Yii::import('application.extensions.phpexcel.JPhpExcel');

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

$xls->addArray($data);

$xls->generateXML('my-test');

		$this->render('create',array(

			'model'=>$model,

		));

	}



Or you can create widget :)

HI qwerty,

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

Thanks

Mithila

how and where we do create widget

maybe this discussion will help - http://phpexcel.codeplex.com/discussions/211116

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:

http://www.yiiframework.com/extension/giiplus/

Hi Sirin,

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

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

Here’s my gii Module config:

‘gii’=>array(

‘class’=>‘system.gii.GiiModule’,

	'password'=>'xxxxx',


	'ipFilters'=>array('127.0.0.1','::1'),


            'generatorPaths'=>array('bootstrap.gii','ext.giiplus'),


                    


	),

and the following is my component’s config:

‘components’=>array(

.....


'bootstrap'=>array(


    'class'=>'ext.bootstrap.components.Bootstrap', 


),

),

What is missing from my system configuration?

Thank you Sirin!