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

Export to excel

8 Answers 424 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 10 Aug 2012, 08:13 AM
Hi,

I was using telerik for asp.net Ajax, and now I am using it's "evolution", telerik for asp.net MVC for a new website.

But I can't find how to export directly as it is displayed, with filter/group/order?

How can we do this?

8 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 13 Aug 2012, 03:39 PM
Hello,

You can use the approach covered in this code library article. 

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Julien
Top achievements
Rank 1
answered on 14 Aug 2012, 06:19 AM
I'm well aware of this code, I already checked it, but I need group to be rendered in the excel file, like it does in asp.net ajax.
0
Petur Subev
Telerik team
answered on 16 Aug 2012, 12:36 PM
Hi Julien,

Basically you can add the group descriptor the same way the other descriptors are added. However on the server side when you have the group descriptor in your request object and you call ToDataSourceResult you will have a hierarchy of AggregateFunctionsGroup. You need to iterate through them recursively and write their items to the sheet in a formatted way (so they look like hierarchy).

Kind regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Julien
Top achievements
Rank 1
answered on 16 Aug 2012, 02:28 PM
So we have also to interpret the group by(check if they are a lot of them), change the column displayed, .... 

Makes a lot of jobs compared to the old tools... Not a big improvement here, it's what I was afraid of.

Do yo have an example of this?
0
Petur Subev
Telerik team
answered on 20 Aug 2012, 08:23 AM
Hello Julien,

The Kendo Wrappers for MVC does not support such Export To Excel feature out-of-the-box. The code library project is just for demonstration purposes and it could be used as a base point which users could extend with more complex logic.
I am afraid that we do not have example that shows how to handle the grouping.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Nikolay
Top achievements
Rank 1
answered on 11 Oct 2012, 10:16 AM
Hi, guys,

I've made an abstracted class which you can inherit in order to export to excel every data type (using reflection).
The class is a modification of this code: http://www.kendoui.com/code-library/mvc/grid/export-grid-to-excel.aspx
Here is the code: http://pastebin.com/29upR781
To use it you should override GetData() (which returns IEnumerable of your data)

Greetings,
Nikolay Kostov
0
Vasilis
Top achievements
Rank 1
answered on 27 Jan 2014, 12:05 PM
What a great idea. Would you be kind enough to share your view page too or any js you have used in conjunction to the controller? I am trying to achieve the same as you but I am slightly stuck...

Many thanks
Vasilis
0
Paul
Top achievements
Rank 1
answered on 19 Jun 2014, 05:56 PM
Does anyone have a small sample app that uses Nikolay's (or any one elses') way to Export to Excel from a Telerik MVC Grid?
Tags
Grid
Asked by
Julien
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Julien
Top achievements
Rank 1
Nikolay
Top achievements
Rank 1
Vasilis
Top achievements
Rank 1
Paul
Top achievements
Rank 1
Share this question
or