yusron
(Yusron)
June 17, 2011, 9:54am
1
hai guys i want to ask.
I want to create report to excel use phpexcel
i try from bega and http://www.yiiframework.com/extension/phpexcel
but just only show meta data.
public function actionExcel()
{
$model=new Kelurahan('search');
if(isset($_GET['yt0']))
{
$dataProvider= $model->search();
$dataProvider->pagination= false; // for retrive all modules
$data = $dataProvider->data;
foreach ($data as $model)
{
$test = array($model);
}
Yii::import('application.extensions.phpexcel.JPhpExcel');
$xls = new JPhpExcel('UTF-8', false, 'test');
$xls->addArray($test);
$xls->generateXML('my-test');
}
$this->render('excel',array(
'model'=>$model,
));
}
in page view admin.php
<?php
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'kelas-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'header' => 'No',
'value'=>'$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize+$row+1'
),
'nama',
array(
'class'=>'CButtonColumn',
'template'=>'{update}{delete}',
),
),
)); ?>
SS like this
naga
(Naga909)
June 23, 2011, 12:26pm
3
yusron:
hai guys i want to ask.
I want to create report to excel use phpexcel
i try from bega and http://www.yiiframework.com/extension/phpexcel
but just only show meta data.
public function actionExcel()
{
$model=new Kelurahan('search');
if(isset($_GET['yt0']))
{
$dataProvider= $model->search();
$dataProvider->pagination= false; // for retrive all modules
$data = $dataProvider->data;
foreach ($data as $model)
{
$test = array($model);
}
Yii::import('application.extensions.phpexcel.JPhpExcel');
$xls = new JPhpExcel('UTF-8', false, 'test');
$xls->addArray($test);
$xls->generateXML('my-test');
}
$this->render('excel',array(
'model'=>$model,
));
}
in page view admin.php
<?php
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'kelas-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'header' => 'No',
'value'=>'$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize+$row+1'
),
'nama',
array(
'class'=>'CButtonColumn',
'template'=>'{update}{delete}',
),
),
)); ?>
SS like this
when my application also do in the same but i cant get it,please help me,i cant get any errors,bt how will see the output
teuku
(Teuku Milist)
July 12, 2011, 11:26am
4
my problem is the same…
it’s funny, a few minute earlier i can download the excell fine.
have you find the solution guys??
teuku
(Teuku Milist)
July 13, 2011, 4:39am
5
Need ut help please bout Excell from YII
Hi tieulonglanh.
I have read you post about a new way to use PHPExcell.
but i have this problem, after i do as you wrote in the manual. when i tried to run the web,
there is an error as below :
Alias "application.extensions.PHPExcel" is invalid. Make sure it points to an existing PHP file.
it’s like that yii wont recognize my setting in the config/main.php :
‘components’=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
//Addition
'excel'=>array(
'class'=>'application.extensions.PHPExcel',
),
in the controller i have wrote it down like this:
//Save to abc.xlsx file
// You can use like PHPExcel documentation from codeplex:
//$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
//$objWriter->save($filename);
$objPHPExcel->saveExcel2007($objPHPExcel,$filename);
can you please correct me if there something missing?
or the file that I have downloaded to be put in the application/extensions is not completed?
thank you for your kind response.