如何在 kartik 导出 yii2 中更改文件名
How to change file name in kartik export yii2
您好,我在我的 yii2 项目中使用 kartik 导出。
<?=
ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-info',
],
'exportConfig' => [
ExportMenu::FORMAT_PDF => false,
ExportMenu::FORMAT_TEXT => false,
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_CSV => false,
ExportMenu::FORMAT_EXCEL => ['filename' => 'Installation_data'.date('dd-MM-yy')],
ExportMenu::FORMAT_EXCEL => ['filename' => 'Installation_data'.date('dd-MM-yy')],
],
])?>
<br><br>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
]); ?>
现在我想更改文件名。我已经添加了文件名选项,但它不起作用。
如何更改名称?
非常感谢任何帮助。
您可以从文档中使用 ExportMenu
选项属性更改文件名 filename
试试这个:
ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-info',
],
'exportConfig' => [
ExportMenu::FORMAT_PDF => false,
ExportMenu::FORMAT_TEXT => false,
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_CSV => false,
ExportMenu::FORMAT_EXCEL => ['filename' => 'Installation_data'.date('dd-MM-yy')],
],
'filename' => 'Installation_data'.date('dd-MM-yy')
])?>
您好,我在我的 yii2 项目中使用 kartik 导出。
<?=
ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-info',
],
'exportConfig' => [
ExportMenu::FORMAT_PDF => false,
ExportMenu::FORMAT_TEXT => false,
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_CSV => false,
ExportMenu::FORMAT_EXCEL => ['filename' => 'Installation_data'.date('dd-MM-yy')],
ExportMenu::FORMAT_EXCEL => ['filename' => 'Installation_data'.date('dd-MM-yy')],
],
])?>
<br><br>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
]); ?>
现在我想更改文件名。我已经添加了文件名选项,但它不起作用。
如何更改名称?
非常感谢任何帮助。
您可以从文档中使用 ExportMenu
选项属性更改文件名 filename
试试这个:
ExportMenu::widget([
'dataProvider' => $dataProvider,
'columns' => $gridColumns,
'dropdownOptions' => [
'label' => 'Export All',
'class' => 'btn btn-info',
],
'exportConfig' => [
ExportMenu::FORMAT_PDF => false,
ExportMenu::FORMAT_TEXT => false,
ExportMenu::FORMAT_HTML => false,
ExportMenu::FORMAT_CSV => false,
ExportMenu::FORMAT_EXCEL => ['filename' => 'Installation_data'.date('dd-MM-yy')],
],
'filename' => 'Installation_data'.date('dd-MM-yy')
])?>