Yii Framework Forum: Reports In Excel And Pdf - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Reports In Excel And Pdf Rate Topic: -----

#1 User is offline   jr_jags 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 05-November 12
  • Location:Philippines

Posted 09 February 2013 - 12:32 AM

Hello guys, Im producing reports in excel and pdf using php excel and mpdf But when I create a report, In my excel report and pdf, it also includes the word Displaying records 10-10 which is present in my CGridView and also there are some numbers which I really dont where it came from.

Here is my code in producing excel and pdf in my controller:

PDF
else if (isset($_POST['PDF'])) {
                $account->attributes = $_POST['AccountForm'];
                $account->searchData2();
                $connection = Yii::app()->db;                
                $sql = $account->sql2;
                $rowcountsql = $account->rowcount2;
                $key = "AuditTrailID";
                $command = $connection->createCommand($rowcountsql);
                $count = $command->queryScalar(); // provide count for pagination
                // create data provider that works with CGridView
                $dataProvider = new CSqlDataProvider($sql, array(
                            'keyField' => $key,
                            'totalItemCount' => $count,
                            'pagination' => array(
                                'pageSize' => $count,
                            ),
                        ));
            $mPDF1 = Yii::app()->ePdf->mpdf();
 
            # You can easily override default constructor's params
            $mPDF1 = Yii::app()->ePdf->mpdf('', 'A5');
 
            # render (full page)
            //$mPDF1->WriteHTML($this->render('index', array(), true));
 
            # Load a stylesheet
            $stylesheet = file_get_contents(Yii::getPathOfAlias('webroot.css') . '/main.css');
            $mPDF1->WriteHTML($stylesheet, 1);
            # renderPartial (only 'view' of current controller)
            $mPDF1->WriteHTML($this->renderPartial('export2', array('dataProvider' => $dataProvider, 'account' => $account, '$auditdate' => $account->auditdate), true));
        
            # Outputs ready PDF
            $mPDF1->Output();
            }




Excel:
$else if (isset($_POST['Excel'])) {
                $account->attributes = $_POST['AccountForm'];
                $connection = Yii::app()->db;
                $account->searchData2();
                $sql = $account->sql2;
                $rowcountsql = $account->rowcount2;
                $key = "AuditTrailID";
                $command = $connection->createCommand($rowcountsql);
                $count = $command->queryScalar(); // provide count for pagination
                // create data provider that works with CGridView
                $dataProvider = new CSqlDataProvider($sql, array(
                            'keyField' => $key,
                            'totalItemCount' => $count,
                            'pagination' => array(
                                'pageSize' => $count,
                            ),
                        ));
                Yii::app()->request->sendFile("AuditTrail Report.xls", $this->renderPartial('export2', array('dataProvider' => $dataProvider, 'account' => $account, '$auditdate' => $account->auditdate),TRUE));
                $this->render('audittrail', array('dataProvider' => $dataProvider, 'account' => $account));
            }

Attached File(s)


0

#2 User is offline   Reza m 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 07-March 12

Posted 09 February 2013 - 02:09 AM

Quote

it also includes the word Displaying records 10-10 which is present in my CGridView


you can hide it by adding this to your gridview
'summaryText'=>false,


Quote

and also there are some numbers which I really dont where it came from.


I think those numbers are gridview pagination numbers, you can turn it off by adding this to your gridview

'enablePagination'=>false,

1

#3 User is offline   jr_jags 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 05-November 12
  • Location:Philippines

Posted 09 February 2013 - 07:43 AM

Oh I tried the 'summaryText'=>false, and it worked but the pagination to false doesnt work, the numbers are still there, here is my code for my grid

<?php
                $factory = new CWidgetFactory();
                $widget = $factory->createWidget($this, 'EExcelView',
                array('dataProvider' => $dataProvider,
                'grid_mode' => 'export',
                'summaryText'=>false,
                'enablePagination' => false,
                'columns' => array('UserName:html:UserName',
                'Status:html:Status',
                'AccountTypeName:html:Account Type Name',
                'Name:html:Account Owner',
                'Email:html:Account Email',
                 )));
                $widget->init();
                $widget->run();
                ?>


I think those numbers at the end of my report are ID's of each record retreive from the database which is my keyField.

Attached File(s)


0

#4 User is offline   jr_jags 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 05-November 12
  • Location:Philippines

Posted 12 February 2013 - 08:15 PM

Anyone who encountered this problem?? and a solution for this one?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users