2017-07-26 98 views
2

我想在Yii2中導出我的表。這裏是我的表格: enter image description hereYii2中的非法字符串偏移'class'

在Kartik Yii2導出時,導出爲Excel時得到非法字符串偏移量'class'。這裏是我的代碼:

<?php 
use yii\helpers\Html; 
use kartik\grid\GridView; 
use yii\widgets\Pjax; 
use yii\bootstrap\Model; 
use yii\helpers\Url; 
use kartik\export\ExportMenu; 



$this->title = Yii::t('app', 'Pelamar Doktor Berdasarkan Usia'); 
$this->params['breadcrumbs'][] = $this->title; 
?> 
<div class="temppelamardoktorusia-index"> 

    <h1><?= Html::encode($this->title) ?></h1> 
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?> 

    <!-- <p> 
     <?= Html::a(Yii::t('app', 'Create Jumlah Pelamar Doktor'), ['create'], ['class' => 'btn btn-success']) ?> 
    </p> --> 
    <?php 

     $gridColumns = [ 
      ['class' => 'yii\grid\SerialColumn'], 
      'TahunDaftar', 
      'lessthan25', 
      'btween25to29', 
      'btween30to34', 
      'btween35to39', 
      'btween40to44', 
      'btween45to49', 
      'morethaneqs50', 
      'NotComplete', 
      'Total', 
      ['class' => 'yii\grid\ActionColumn'], 
     ]; 

     //Renders a export dropdown menu 
     echo ExportMenu::widget([ 
      'dataProvider' => $dataProvider, 
      'columns' => $gridColumns, 
      'fontAwesome' => true, 
      ]); 
    GridView::widget([ 
      'dataProvider' => $dataProvider, 
      'filterModel' => $searchModel, 
      'columns' => $gridColumns, 
      'exportConfig'=> [ 
       GridView::CSV=>[ 
        'label' => 'CSV', 
        'icon' => '', 
        'iconOptions' => '', 
        'showHeader' => false, 
        'showPageSummary' => false, 
        'showFooter' => false, 
        'showCaption' => false, 
        'filename' => 'yii', 
        'alertMsg' => 'created', 
        'options' => ['title' => 'Semicolon - Separated Values'], 
        'mime' => 'application/csv', 
        'config' => [ 
         'colDelimiter' => ";", 
         'rowDelimiter' => "\r\n", 
        ], 
       ], 
      ], 
     ]); ?> 
</div> 

結果:非法字符串偏移'class'。 以下是錯誤消息:

enter image description here

enter image description here

enter image description here 我在做什麼錯? 有什麼想法解決這個問題嗎?在此先感謝

回答

0

您輸入了錯誤GridView

更改此:use yii\grid\GridView;

通過卡爾蒂克的:use kartik\grid\GridView;

+0

呀,三江源校正。但是代碼仍然不起作用。據說非法字符串偏移量'class'。我在 – r34627673

+0

以上編輯了我的問題你在哪一行得到錯誤? – gmc

+0

我剛剛在上述問題上發佈了錯誤消息 – r34627673

相關問題