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




3 Replies 1 reply marked as answer

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team September 7, 2023 11:48 AM UTC

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


Marked as answer

BS Bill Seddon September 7, 2023 02:38 PM UTC

Great answer.  Thank you very much.



SG Suganya Gopinath Syncfusion Team September 8, 2023 11:12 AM UTC

We are glad, please get back to us for further assistance. We are marking this ticket as closed. 


Loader.
Up arrow icon