本文介绍了如何在Yii2 krajee网格导出中更改导出工作表/文档属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已使用yii2 krajee导出来导出网格数据。
如何修改默认标题,description,lastmodifiedby?

We have used yii2 krajee export for exporting grid data.
How can we modify default title, description , lastmodifiedby?

echo ExportMenu::widget([
    'dataProvider' => $dataProvider,
    'columns' => $gridColumns,
    'target' => ExportMenu::TARGET_SELF,
    'exportConfig' => [
        ExportMenu::FORMAT_PDF => false,
    ],
    'filename' => 'export-list_' . date('Y-m-d_H-i-s'),        
]);


推荐答案

尝试一下:
这是一个示例CSV。

Try This :Here is a example of CSV. You can do like wise for others also.

 use yii\helpers\Html;
    use kartik\grid\GridView;
    use kartik\export\ExportMenu;

    $gridColumns = [
            ['class' => 'yii\grid\SerialColumn'],
            'id',
            'name',
            'desc',
            ['class' => 'yii\grid\ActionColumn'],
        ];

        // Renders a export dropdown menu
        echo ExportMenu::widget([
            'dataProvider' => $dataProvider,
            'columns' => $gridColumns
        ]);

        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",
                    ], 
                ],
            ],
        ]);  

这篇关于如何在Yii2 krajee网格导出中更改导出工作表/文档属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 02:35