Yii出口到excel

时间:2015-09-01 09:58:07

标签: php yii phpexcel

分机https://github.com/hscstudio/yiiheart

如何从sql query \ array导出数据?条件是模型中没有数据。目前的状况:

Declare @StartDate datetime 
Declare @EndDate datetime 
Set @StartDate = '2015-07-07 01:31:38.000' 
Set @EndDate = '2015-08-21 01:14:14.000' 
Set @StartDate = convert(datetime, dateadd(hour, 7, @StartDate), 100) 
Set @EndDate = convert(datetime, dateadd(hour, 7, @EndDate), 100)

select distinct a.NAME [User Name]
               ,b.USERNAME [Role Modified By]
               ,convert(datetime, dateadd(hour, -7, b.CREATEDDATETIME), 100) [Modified DateTime]
               ,case b.LOGTYPE 
                   when 0 then 'Added'
                   when 1 then 'Removed' 
                end as Status
               ,d.Text Role 
from USERINFO a (nolock) 
join(
    select (case when logtype = 0 then dbo.CONPEEK(CAST(dbo.CONPEEK(data, 16) AS varbinary(8000)), 2)
                 when logtype = 1 then dbo.CONPEEK(CAST(dbo.CONPEEK(data, 10) AS varbinary(8000)), 2)           
            end) AS UserNam
           ,USERNAME
           ,CREATEDDATETIME
           ,logtype
           ,(case when logtype = 0 then dbo.CONPEEK(CAST(dbo.CONPEEK(data, 15) AS varbinary(8000)), 2)
                  when logtype = 1 then dbo.CONPEEK(CAST(dbo.CONPEEK(data, 9) AS varbinary(8000)), 2) 
             end) as SecurityRole    
    from SYSDATABASELOG (nolock) where TABLE_=65492 and data !='')  b  
on a.id = b.UserNam 
left outer join [DynamicsAX_model].[dbo].[modelsecurityrole] c (nolock) on b.SecurityRole =c.rolehandle 
join [modelelementlabel] d (nolock) on c.labelid = d.labelid 
                                   and c.LABELMODULE = d.module 
                                   and d.Language='en_us' 
where b.CREATEDDATETIME >= @StartDate and b.CREATEDDATETIME <=@EndDate order by [Modified DateTime] desc    

public function actionExport()
{
    $model = new Element;
    $model->unsetAttributes();  // clear any default values
    if (isset($_POST['Element']))
        $model->attributes = $_POST['Element'];
    $exportType = $_POST['fileType'];
    $this->widget('ext.heart.export.EHeartExport', array(
        'title' => 'List of Element',
        'dataProvider' => $model->search(),
        'filter' => $model,
        'grid_mode' => 'export',
        'exportType' => $exportType,
        'columns' => array(
            'id',
            'name',
            'type_id',
            'f_filter',
            'comment',
            'measure',
            'name_pk',
            'name_value',
        ),
    ));
}
  

错误500 call_user_func_array()期望参数1有效   回调,没有给出的数组或字符串

0 个答案:

没有答案