Yii installation and use of Excel extensions, yii installation of excel extensions
This document describes how to install Yii and use Excel extension. We will share this with you for your reference. The details are as follows:
1. Download EExcelBehavior to the Project Extension directory.
2. Download phpexcl to the extension directory
3. Controller call:
/*** Export list, Security Fund list of each seller */public function actionExport () {$ model = new Company ('search '); $ model-> unsetAttributes (); // clear any default values $ model-> zc_deposit_status = 2; // merchants approved by the security fund $ companys = $ model-> search (); $ this-> toExcel ($ companys, array ('zc _ name', 'zc _ deposit');}/*** export list, details of changes to the merchant's Security Fund */public function actionExportDeposit ($ id) {$ model = new CmpDeposit ('search'); $ model-> unsetAttributes (); // clear any default values $ model-> zm_id = $ id; $ data = $ model-> search (); $ company = Company: model () -> findByPk ($ id); $ this-> toExcel ($ data, '', $ company-> zc_name. 'network shop guarantee detail');} public function behaviors () {return array ('eexcelview' => array ('class' => 'ext. eexcelview. EExcelBehavior ',),);}
4. Usage:
* @param null string|CDataProvider|array $model the data provider for the grid. * @param null array $columns array with specif columns and its format. Defaults to all attributes. * @param null string $title title for the file * @param null array $documentDetails details of the document * @param null string $exportType format to export (Excel5,Excel2007, PDF, HTML, CSV). Defaults to Excel2007 (xlsx) */public function toExcel($model=null, $columns=array(), $title=null, $documentDetails=array(), $exportType='Excel2007')