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
In Kendo UI Code Library section there are some examples which demonstrate how to achieve the desired functionality:
Regards,
Iliana Nikolova
the Telerik team
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
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
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.
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.
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
regards
Kendo UI Q3 2014 official release is planned for the middle of November.
Regards,
Iliana Nikolova
Telerik
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
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
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
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
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>
Atanas Korchev
Telerik
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!
You can use the approach demonstrated here.
Regards,
Daniel
Telerik