This is a migrated thread and some comments may be shown as answers.

kendo-excelexport-column template

1 Answer 1359 Views
Grid
This is a migrated thread and some comments may be shown as answers.
alex
Top achievements
Rank 1
Iron
Veteran
alex asked on 01 Mar 2021, 10:37 AM

hi, I would like to know how it is possible to insert a template for the single column.
I would like to apply a template to the cell for example to print a text and not the value of the field

Something like this:

<kendo-grid-excel fileName="{{fileName}}" [fetchData]="_allData">
    <ng-container *ngFor="let item of _excelColumns">
        <kendo-excelexport-column [field]="item.field" [title]="item.title" [hidden]="item.hidden" [cellOptions]="item.cellOptions" [width]="item.width">
            <ng-template let-dataItem>
                Hello world
              </ng-template>
        </kendo-excelexport-column>
    </ng-container>
</kendo-grid-excel>

 

 

hello world not displayed

 

Great regards,

Alex

 

 

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 03 Mar 2021, 09:06 AM

Hi Alex,

Thank you for the provided information and code snippet.

Custom templates are a known limitation for exporting to Excel. It is documented in this article:

"The Grid does not export its detail template to Excel. The reason for this behavior is that the detail template might contain arbitrary HTML which cannot be converted to Excel column values."

You can, however, use different data when exporting your grid to excel. A custom fetchData callback could be used for this purpose. A little more info and an example are present here.

In this example I have used a simple map function to displace the original value of the cell with a different, custom value.

Hope this helps - please do let me know if it does and/or if you require any further assistance on this issue.

 

Regards,
Georgi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
alex
Top achievements
Rank 1
Iron
Veteran
Answers by
Georgi
Telerik team
Share this question
or