Yii installation and use of Excel extensions, yii installation of excel extensions

Source: Internet
Author: User

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')

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.