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

Generic Grid Excel Export

15 Answers 476 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 06 May 2013, 08:29 AM
Hello,

I am using
KendoUI with MVC wrappers. I want to make all Grids in my project to be
exportable to csv/ excel. For this I like to have a generic export function.

I found
following blog post (http://www.kendoui.com/blogs/teamblog/posts/13-03-12/exporting_the_kendo_ui_grid_data_to_excel.aspx) that suits perfectly for me.

However,
this post describe how to make a Grid exportable that is initialised via pure
JavaScript.

Is there
any solution how to make this working for the MVC wrappers?

Thank you

15 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 07 May 2013, 08:59 AM
Hello Tim,

In Kendo UI Code Library section there are some examples which demonstrate how to achieve the desired functionality: 
Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tim
Top achievements
Rank 1
answered on 07 May 2013, 11:02 AM
Thank you Iliana,
I have already seen this code examples. However, they require a implementation for each Grid. I am using > 50 Grids in my application and like to avoid writing simple export code for each time. Thus I am searching for a more generic way that simple exports all provided columns (like the one provided in the link below).
Is it possible to extend the KendoUI MVC Wrapper to make this possible?

Thank you
0
Iliana Dyankova
Telerik team
answered on 08 May 2013, 02:20 PM
Hi Tim,

Generally speaking, Exporting to Excel / CSV is out-of-scope of Kendo UI Grid supported features and in order to be achieved a custom solution is needed. The examples I pointed represent a possible implementation, however in case they do not fit your requirements you should implement your own logic / solution to achieve the desired result.
 
Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
pratima
Top achievements
Rank 1
answered on 05 May 2014, 11:11 AM
Hi,
I am also trying to export a grid to excel sheet. I want to do this on the client side only.
I tried exporting using the html grid using the following code. Which works fine.

$("#btnExport").on('click', function ( e ) {
    alert("exporting to xls");
    window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
    e.preventDefault();
});


But i dont know how to make it work for a kendo grid.
Is it possible to do this on the client side or i will have to use some kind of webservice to do so.
0
Jako
Top achievements
Rank 1
answered on 27 Oct 2014, 12:00 PM
Hello Iliana 

I am using the first suggested excel export. How can I export price values ( doubles ) and till be able to do calculations in excel.

Current Setup:    row.CreateCell(1).SetCellValue(province.Value.ToString("N2"));

The values display correctly in excel, but do not want to format even after selected numerical.

Help much appreciated.



0
Iliana Dyankova
Telerik team
answered on 29 Oct 2014, 11:13 AM
Hi guys,

I am glad to inform you that client Excel/ PDF Export for Kendo UI Grid will be available with Q3 2014 release (the Beta version will be released today or tomorrow depending on your time zone).

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Oliver
Top achievements
Rank 1
answered on 30 Oct 2014, 07:32 AM
Have you got a date for the final release?

regards
0
Iliana Dyankova
Telerik team
answered on 31 Oct 2014, 02:43 PM
Hi Oliver,

Kendo UI Q3 2014 official release is planned for the middle of November.

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
VasVas
Top achievements
Rank 1
answered on 05 May 2015, 06:01 AM

Dear Iliana,

I have this chanlenge in exporting to excel. At first I used a custom script to create EXCEL files and download as there was a problem in IE I now use the latest MVC WRAPPER version and use the built in EXCEL function. But as my projects replaces an existing project , is there a way not download the excel but rather grab the excel and open it dirctly from excel using kendo.ooxml or other method to grab the file and show it with out redirecting to a url. This must work in IE if possible.

 Ariel

0
VasVas
Top achievements
Rank 1
answered on 06 May 2015, 10:45 AM

Hi Iliana 

I have grid that is declared in server side. Is there a way to export it with columns right to left?(I see the demo when all is client side. when is declared as server side does not work - doesn't recognize the grids workbook)/

Thanks

0
Atanas Korchev
Telerik team
answered on 07 May 2015, 05:46 AM

Hello Ariel,

We are not sure what you mean by "doesn't recognize the grids workbook". Can you clarify?

Otherwise here is how to export the grid in RTL: http://docs.telerik.com/kendo-ui/web/grid/excel-export#rtl

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
VasVas
Top achievements
Rank 1
answered on 07 May 2015, 11:04 AM

I have a grid declared server side

@(Html.Kendo().Grid<MyModel>().Name("grid").Excel(excel=>excel.FileName("downLoad.xlsx)).columns...

 

javaScript 

var $grid = $("#grid").data("kendoGrid");

$grid.excelExport(function(e){

    var sheet = e.workbook.sheets[0];
    for (var i = 0; i < sheet.rows.length; i++) {
    sheet.rows[i].cells.reverse();
   for (var ci = 0; ci < sheet.rows[i].cells.length; ci++) {
   sheet.rows[i].cells[ci].hAlign = "right";
}
}

}

when  I try in javaScript to attach function excelExport raises error: "object doesn't support property or method 'excelExport'".

do you have a way to print from right to left with kendo server grids?

Thanks

 

0
Atanas Korchev
Telerik team
answered on 08 May 2015, 06:39 AM

Hello Ariel,

The grid indeed doesn't have such a method hence the JS error. All methods are documented here.

The method you are looking for is saveAsExcel

You can subscribe to the ExcelExport event from C# like this:

@(Html.Kendo().Grid<MyModel>().Name("grid").Events( e => e.ExcelExport("onExcelExport"))
<script>
function onExcelExport(e) {
  
}
</script>

Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
VasVas
Top achievements
Rank 1
answered on 18 May 2015, 12:10 PM

HI

to export my kendo grid to excel, I'm using  SaveAsExcel().function.

The exported excel is from left to right. 

is there a way that the opened excel should be from right to left?

(the column A should start from right, not reversing the rows..)

Thanks!

 

0
Daniel
Telerik team
answered on 20 May 2015, 11:18 AM
Hi,

You can use the approach demonstrated here.

Regards,
Daniel
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Tim
Top achievements
Rank 1
pratima
Top achievements
Rank 1
Jako
Top achievements
Rank 1
Oliver
Top achievements
Rank 1
VasVas
Top achievements
Rank 1
Atanas Korchev
Telerik team
Daniel
Telerik team
Share this question
or