Kartik ExportMenu, exported document's title

Hi everybody.
I’m developing a web application to control the information of some energy groups. I’m using kartik GridView and ExportMenu. The problem is that I need to set the document’s title on the header to the exported Excel / Pdf exported file,

I’ve searched other posts but I can’t find anything specific.

Thanks in advance for your help.

1 Like

I’m not sure if I’m understanding your question properly, hopefully I am, but when I use the widget I set the filename property

echo ExportMenu::widget([
	'dataProvider' => $dataProviderExport,
	'columns' => $exportColumns,
	'filename'=>'Projects_Export',
	'dropdownOptions' => [
		'label' => 'Export',
		'class' => 'btn btn-secondary'
	],
]);

Typically, I include the Date/Time in the filename as well.

1 Like

Hi, thanks for your reply.
What I need is to place some title and image at documents Header.
For example:


             DAILY REPORT NUMBER 5 (This is what I need to include on header)

–> Gridview Table Data



You can use contentBefore to add some content (string) before the table starts on. Like:

        <?= ExportMenu::widget([
                'dataProvider' => $dataProvider,
                'columns' => $searchModel->allGridColumns,
                'fontAwesome' => false,
                'target' => ExportMenu::TARGET_BLANK,
                'deleteAfterSave' => true, // this will delete the saved web file after it is streamed to browser,
                'filename' => 'municipios_Aris' . date('Y-m-d_H-i-s'),
                'folder' => Yii::getAlias('@runtime'.'/export'),
                'contentBefore' => [
                    ['value' => 'YOUR TITLE'],
                ],
                'dropdownOptions' => [
                    'label' => 'Exportar Para',
                    'class' => 'btn btn-default'
                ]
            ])
        ?>

Remember that ‘contentBefore’ => [ [‘value’ => ‘YOUR TITLE’], … ] it’s a Array of Arrays, so every array inside the array ‘contentBefore’ will be a row added to your content before the table. Hope I helped you