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
    ++;
           
    }      
           
    ...
    }
  • 相关阅读:
    螺旋折线——第九届蓝桥杯C语言B组(省赛)第七题
    组合问题
    八皇后
    01背包(详解)
    最长递增子序列
    棋盘游戏
    The Accomodation of Students
    P3157 [CQOI2011]动态逆序对
    Building a Space Station
    焚风现象(差分模板题)
  • 原文地址:https://www.cnblogs.com/xiongsd/p/3109063.html
Copyright © 2011-2022 走看看