Hello
Matias,
The following
example demonstrates how to export multiple grid to a single Excel document. Generally you can modify the code to export only a single grid or multiple grids. Nevertheless, in case you need to export two files, one that will contains the single grid and another one that will contains the multiple grids you can execute the same logic to export twice. Please check out the following code snippet.
$(
"#export"
).click(
function
(e) {
// trigger export of the products grid
$(
"#products"
).data(
"kendoGrid"
).saveAsExcel();
// trigger export of the orders grid
$(
"#orders"
).data(
"kendoGrid"
).saveAsExcel();
// wait for both exports to finish
$.when.apply(
null
, promises)
.then(
function
(productsWorkbook, ordersWorkbook) {
// create a new workbook using the sheets of the products and orders workbooks
var
sheets = [
productsWorkbook.sheets[0],
ordersWorkbook.sheets[0]
];
sheets[0].title =
"Products"
;
sheets[1].title =
"Orders"
;
var
workbook =
new
kendo.ooxml.Workbook({
sheets: sheets
});
// save the new workbook,b
kendo.saveAs({
dataURI: workbook.toDataURL(),
fileName:
"ProductsAndOrders.xlsx"
})
});
// this will create another Excel document.
$(
"#products"
).data(
"kendoGrid"
).saveAsExcel();
$.when.apply(
null
, promises)
.then(
function
(productsWorkbook) {
// create a new workbook using the sheets of the products and orders workbooks
var
sheets = [
productsWorkbook.sheets[0]
];
sheets[0].title =
"Products"
;
var
workbook =
new
kendo.ooxml.Workbook({
sheets: sheets
});
// save the new workbook,b
kendo.saveAs({
dataURI: workbook.toDataURL(),
fileName:
"ProductsAndOrders.xlsx"
})
});
});
Regards,
Kostadin
Telerik by Progress
Check out the new
UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.