Export does not include Header Template

Is there a way to include the header template in the excel export?


3 Replies

RS Renjith Singh Rajendran Syncfusion Team March 9, 2022 09:33 AM UTC

Hi Jason, 
 
Greetings from Syncfusion support. 
 
Based on this scenario, we suggest you to ensure to assign the custom HeaderTemplate content to args.Cell.Value inside the ExcelHeaderQueryCellInfoEvent event handler to display the custom header texts in exported file. Please refer and use as like the code below, 
 
 
    <GridEvents OnToolbarClick="ToolbarClickHandler" ExcelHeaderQueryCellInfoEvent="ExcelHeaderQueryCellInfoEvent" TValue="Order"></GridEvents> 
 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"> 
            <HeaderTemplate> 
                <div>Custom Header Text for OrderID</div> 
            </HeaderTemplate> 
        </GridColumn> 
 
    public void ExcelHeaderQueryCellInfoEvent(ExcelHeaderQueryCellInfoEventArgs args) 
    { 
        if (args.Column.Field.Equals("OrderID")) 
        { 
            //assign your custom header template content here 
            args.Cell.Value = "Custom Header Text for OrderID"; 
        } 
    } 
 
 
We are also attaching the sample for your reference, kindly download and refer the sample form the link below, 
 
Please get back to us if you need further assistance. 
 
Regards, 
Renjith R 



JB Jason Bishop March 9, 2022 08:21 PM UTC

Thanks!



RS Renjith Singh Rajendran Syncfusion Team March 10, 2022 09:56 AM UTC

Hi Jason, 
 
Thanks for your update. Please get back to us if you need further assistance. 
 
Regards, 
Renjith R 


Loader.
Up arrow icon