Unplanned
Last Updated: 13 Oct 2020 10:10 by ADMIN
Jurgen
Created on: 22 Sep 2020 15:20
Category: Grid
Type: Feature Request
1
Customize the Excel file before it gets to the client

I want to edit the Excel file the grid exports before it gets to the user. For example, to add a sheet with data I want to generate, or to change columns, formats, colors.

----

ADMIN EDIT

I have attached to this post an example that shows how you can generate your own exported file so you can customize colors, sheets and so on. It also shows how to cache the DataSourceRequest of the grid so you can extract only the current page or all data, and so you can also apply the current grid sorts/filters and so on to the export. This also lets you add metadata to the sheet such as the current user settings such as filters that resulted in this filter.

----

Attached Files:
3 comments
ADMIN
Marin Bratanov
Posted on: 13 Oct 2020 10:10

Hello Ed,

While you could get the visible columns through the grid state, at this point there isn't a direct way to add such mapping, since there is only the index of the column. We made this feature request on your behalf for exposing the Field in the state too: https://feedback.telerik.com/blazor/1489571-add-field-property-in-grid-s-columnstate. That would help in this case, I think, and you can Follow it to get status updates via email. We've also added your Vote on your behalf to raise its priority.

In the meantime you could consider matching the indexes in the state with custom column descriptor collection, similarly to the approach from my post at the end of this page.

To also cover the case from your support ticket here for completeness - the need for this is likely to diminish (of not go away entirely) once export for all pages is implemented for OnRead: https://feedback.telerik.com/blazor/1469312-include-all-pages-in-excel-export-should-work-with-onread. I'm also attaching here the sample from the ticket that shows the general concept of getting the grid state and looping through it.

Regards,
Marin Bratanov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Attached Files:
Edward
Posted on: 12 Oct 2020 13:14

Hi Marin,

Thank you for the example. Can you also add how to check visible columns and only add them in the generated excel file? Users may hide/unhide columns using the FilterMenu or re-arrange them in the grid.

Thanks,

Ed

ADMIN
Marin Bratanov
Posted on: 22 Sep 2020 16:01

I have edited the opener post to add an example and some explanations that you can use as base for further development.

 

Regards,
Marin Bratanov
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/.