zoukankan      html  css  js  c++  java
  • Yii GridView export excel

    publicfunction actionAdmin()
    {
            $model
    =newEmployee('search');
            $model
    ->unsetAttributes();  // clear any default values
           
    if(isset($_GET['Employee']))
           
    {
                    $model
    ->attributes = $_GET['Employee'];
                   
    // save search parameters to the session data
                   
    Yii::app()->user->setState('EmployeeSearchParams', $_GET['Employee']);
           
    }
            $this
    ->render('admin',array(
                   
    'model'=> $model,
           
    ));
    }

    publicfunction actionExcel()
    {
           
    ...
            $model
    =newEmployee('search');
            $model
    ->unsetAttributes();  // clear any default values
           
    // retrieve the search parameters from the session data
            $params
    =Yii::app()->user->getState('EmployeeSearchParams');
           
    if( isset($params))
                    $model
    ->attributes = $params;
           
    // retrieve the data by CActiveDataProvider
            $dataProvider
    = $model->search();
            $data
    = $dataProvider->getData();
           
    ...
            $i
    =5;
           
    foreach($data as $record){
           
    {      
                    $objPHPExcel
    ->setActiveSheetIndex()->setCellValue('B'.$i, $record->e_no);
                   
    ...
                    $i
    ++;
           
    }      
           
    ...
    }
  • 相关阅读:
    1103: [POI2007]大都市meg
    bzoj2809: [Apio2012]dispatching
    bzoj3668: [Noi2014]起床困难综合症
    bzoj4025: 二分图
    bzoj4027: [HEOI2015]兔子与樱花
    bzoj3155: Preprefix sum
    http状态码status
    js改变触发
    eq
    error_reporting()
  • 原文地址:https://www.cnblogs.com/xiongsd/p/3109063.html
Copyright © 2011-2022 走看看