• Make Report of Database to Excel on YII Framework

    by  • 19 April, 2012 • Script • 3 Comments

    Do you using YII Framework ? Want to Export the data on Database to Excel on YII Framework ?
    You can follow this script. Feel free to comment if you have a problem.. i’m still new too in yii :D
    Add this script to your Controller, Example ContentController.php

    public function actionExcel() { $model=Content::model()->findAll(); Yii::app()->request->sendFile(‘MyContent.xls’, $this->renderPartial(‘excel’,array( ‘model’=>$model, ),true) ); } Make sure you already configures it on function rules array(‘allow’, // allow all users to perform ‘index’ and ‘view’ actions ‘actions’=>array(‘index’,'view’,'excel’), ‘users’=>array(‘*’), ), Make file excel.php on your views folder. (example on content folder)

    DATA CONTENT

    
    

    titlecontent

    id

    You can process the excel by typing : http://localhost/index.php?r=content/excel

    About

    Dedy Isnandar sekarang bekerja pada salah satu perusahaan telekomunikasi di Indonesia. Sangat menyukai (dan hobi mengoleksi) Materi tentang Internetwork, Linux dan materi-materi belajar lainnya. Tertarik berdiskusi ??

    http://www.dedyisn.net

    3 Responses to Make Report of Database to Excel on YII Framework

    1. ceNo Gravatar
      6 June, 2012 at 9:20 am
      Mozilla Firefox 12.0 Ubuntu Linux

      hola, en efecto genera el excel sin embargo me aparece el codigo html de la tabla en el excel

    2. ceNo Gravatar
      6 June, 2012 at 9:21 am
      Mozilla Firefox 12.0 Ubuntu Linux

      hello, in effect generates excel but I get the html code of the table in excel

      • dedyisnNo Gravatar
        18 June, 2012 at 2:59 pm
        Mozilla Firefox 12.0 Windows XP

        can you post your code in here. But if you have difficult, you can view the video from http://www.youtube.com/user/Gustalh/videos

        There are a video about how to generates the excel

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    CommentLuv badge