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
    ++;
           
    }      
           
    ...
    }
  • 相关阅读:
    Zabbix5 Frame 嵌套
    Zabbix5 对接 SAML 协议 SSO
    CentOS7 安装 Nexus
    CentOS7 安装 SonarQube
    GitLab 后台修改用户密码
    GitLab 查看版本号
    GitLab Admin Area 500 Error
    Linux 安装 PostgreSQL
    Liger ui grid 参数
    vue.js 是一个怪东西
  • 原文地址:https://www.cnblogs.com/xiongsd/p/3109063.html
Copyright © 2011-2022 走看看