generate a file witl Excel

I have data which are stored in database and i want to generate an file with excel , i need help.

Take a look at this extension.

thank you Zakaria but this code where ihave to put it ?

$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 is just an example.

Take a look at the documentation of the library phpExcel for detail about the available functions.

thanks alot Zaccaria, i will see it :)

i 'm sorry but the extension that you give to me had only two files JphpExcel.php and php-excel.class.php and if i want to generate a file excel, the code html appears in this file so what i can do?? :(

You are right, I gave you the wrong extension.

Here is the correct one: there are no file, just an explaination about how to install under Yii the phpExcel library.

Sorry for time lost!!

If you didn’t think about it, there is CSV (comma separated spreadsheet) which is easier to generate and works with every spreadsheet software.

For CSV take a look at this post.

i use this library :phpExcel1.7.3c and i put it in extensions but when i try to use it i have an error message:include(PHPExcel.php): failed to open stream: No such file or directory

this is a peace of my code source in the view:

$phpExcelPath = Yii::getPathOfAlias(‘ext.PHPExcel.Classes.*’);

//require_once (‘Classes/PHPExcel.php’);

$objPHPExcel=new PHPExcel();

       $objPHPExcel->getProperties()->setCreator("Maarten Balliauw");

$objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");

$objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");

$objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");

$objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");

$objPHPExcel->getProperties()->setKeywords("office 2007 openxml php");

You miss something like:


Yii::import('ext.PHPExcel.Classes.*');

Or


requireOnce(Yii::getPathOfAlias('ext.PHPExcel.Classes.PHPExcel').'.php');

Something that will include the file with the definition if PHPExcel.