- Home
- Forum
- JavaScript - EJ 2
- Group caption in Excel export
Group caption in Excel export
The grid lets a user change the group caption by providing a template providing alternative content. However the export to Excel seems to ignore the template and instead outputs the default group template.
Is there an equivalent feature to control how the group caption appears in Excel Alternatively, is it possible to remove the group when exporting to Excel (but still keep the group in the grid in the web page)?
Thanks
Hi Bill,
Greetings from Syncfusion support
Before we start providing solution on your query, we would like to inform you that by default the template is used only for display purposes. By using template, you can show the customized value in the Grid. All the Grid actions like Filtering, Searching, Grouping, Sorting, etc., are performed with the Grid’s dataSource value based on its column field name and its type not with the customized value. This is the intended behavior of EJ2 Grid.
Since your requirement is to Export the customized text of Group caption template in the Excel document, you can achieve your requirement by using the exportGroupCaption event of Grid. This event gets triggered before exporting each caption row to PDF/Excel/CSV document. You can also customize the export caption row values. Please refer the below code example and sample for more information.
|
function exportGroupCaption(args) { //exportGroupCaption event of Grid args.captionText = args.data.field + '-' + args.data.count + '-' + 'records'; //set your customized caption row values here to export }
|
Sample: https://stackblitz.com/edit/y2akis-jm58xg?file=index.ts,index.html
API: https://ej2.syncfusion.com/documentation/api/grid/#exportgroupcaption
Screenshot:
Group caption in Grid
Group caption in Excel document
Regards,
Rajapandi R
Great answer. Thank you very much.
We are glad, please get back to us for further assistance. We are marking this ticket as closed.
- 3 Replies
- 3 Participants
- Marked answer
-
BS Bill Seddon
- Sep 6, 2023 10:11 PM UTC
- Sep 8, 2023 11:12 AM UTC