Hi Folks
i using http://phpexcel.codeplex.com
i have a problem
get the next error
when run the action "excel"
the code:
<?php
Yii::import('application.components.PHPExcel171.*');
require_once 'Classes/PHPExcel.php';
/** PHPExcel_IOFactory */
require_once 'Classes/PHPExcel/IOFactory.php';
class XXXController extends CController
{
public function actionExcel()
{
$XLS = new PHPExcel();
$Sheet = $XLS->getActiveSheet();
$Sheet->setCellValue('A1', "File Nr 2");
$Sheet->getStyle('A1')->getFont()->setName("Tahoma");
$Sheet->getStyle('A1')->getFont()->setsize(18);
$Sheet->getStyle('A1')->getFont()->setBold(true);
echo "here OK";
$Writer = new PHPExcel_Writer_Excel5($XLS);
echo "here .....";
$Writer->save(Yii::app()->basePath().DIRECTORY_SEPARATOR."xxxxFileNr2.xls");
}
when run the "tests" of PHPExcel, work fine, but in Yii not
my guide
http://www.yiiframework.com/doc/guide/extension.integration
thanks
mikl
(Mike)
2
That’s a webserver error. Check the error log of your webserver. It should help you to find the problem.
the error is
the problem: PHPExcel_Writer_Excel5.php not exists,
the class is in file Excel5.php
my solution
create PHPExcel_Writer_Excel5.php and put
<?php
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5.php';
?>
other solution?
mikl
(Mike)
4
If it works, that’s absolutely fine.
Edit:
Oh, or you could
require_once( PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5.php');
before you use that class.
that’s strange, is already included Excel5.php
but yii gives an error
only work if create PHPExcel_Writer_Excel5.php in the same folder(PHPExcel/Writer)
and put
<?php
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5.php';
?>
basva
(Basvanvelzen)
6
I also use PHPExcel.
I had the same issue, and for me had to do with autoloading conflicts.
I did:
spl_autoload_unregister(array('YiiBase','autoload'));
require_once('PHPExcel/IOFactory.php');
before I started to output the report and after finishing the export put it back to original state:
spl_autoload_register(array('YiiBase','autoload'));
Hope it helps…
crioz
(Info)
7
I had the same problem with PHPExcel - now this is a history. "Basva" you are right - this is the right solution. thank you