在 Kartik Yii2 导出中,在导出为 Excel 时出现非法字符串偏移“类”。这是我的代码:
<?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'。这是错误消息: