Yii安裝與使用Excel擴展的方法
本文實例講述了Yii安裝與使用Excel擴展的方法。分享給大家供大家參考,具體如下:
1.下載EExcelBehavior到項目擴展目錄下

2.下載phpexcl到擴展目錄

3.控制器調用:
/**
* 導出列表,各商家保障金列表
*/
public function actionExport(){
$model = $model=new Company('search');
$model->unsetAttributes(); // clear any default values
$model->zc_deposit_status = 2;//保障金審核通過的商家
$companys = $model->search();
$this->toExcel($companys,array('zc_name','zc_deposit'));
}
/**
* 導出列表,商家保障金變動明細
*/
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.'網鋪保障金明細');
}
public function behaviors()
{
return array(
'eexcelview'=>array(
'class'=>'ext.eexcelview.EExcelBehavior',
),
);
}
4.具體用法:
* @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')
更多關于Yii相關內容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結》、《php優(yōu)秀開發(fā)框架總結》、《smarty模板入門基礎教程》、《php操作office文檔技巧總結(包括word,excel,access,ppt)》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家基于Yii框架的PHP程序設計有所幫助。
相關文章
解決Laravel無法使用COOKIE和SESSION的問題
今天小編就為大家分享一篇解決Laravel無法使用COOKIE和SESSION的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10
PHPMailer ThinkPHP實現(xiàn)自動發(fā)送郵件功能
這篇文章主要為大家詳細介紹了PHPMailer ThinkPHP實現(xiàn)自動發(fā)送郵件功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-06-06
Yii 2.0實現(xiàn)聯(lián)表查詢加搜索分頁的方法示例
這篇文章主要給大家介紹了關于利用Yii 2.0實現(xiàn)聯(lián)表查詢加搜索分頁的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面來跟著小編一起學習學習吧。2017-08-08
PHP中把stdClass Object轉array的幾個方法
PHP和JS通訊通常都用json,但用 json 傳過來的數(shù)組并不是標準的array,而是 stdClass 類型。那么我們可以參考下面的幾個方法進行轉換。2014-05-05
thinkphp5框架實現(xiàn)的自定義擴展類操作示例
這篇文章主要介紹了thinkphp5框架實現(xiàn)的自定義擴展類操作,結合實例形式簡單分析了thinkPHP5在extend目錄下建立自定義擴展類的具體操作步驟與相關實現(xiàn)技巧,需要的朋友可以參考下2019-05-05

