3 Answers, 1 is accepted
0
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.
Regards,
Kostadin
Telerik by Progress
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.
0
Matias
Top achievements
Rank 1
answered on 20 Oct 2016, 03:17 PM
Hello Kostadin,
As I understand the code snippet you provided, with the same trigger (e.g. a button) I can fire two exports at the same time, one with every grid in a single file, and one with the desired grid in another file, generating the 2 files at the same time.
What I would like to achieve is, triggering the 2 exports separately, for example with 2 different buttons. In "ButtonA" I fire the script that export every grid in a single file, and in "ButtonB" I fire the export that generates a file for a single grid.
Is that possible?
Thank you very much.
0
Hi Matias,
You can achieve that by using a single button to export the multiple grid and a single button to export only one grid. The multiple grid exporting is demonstrated in the provided sample and you can use the following code to export only a single grid.
Keep in mind you need to check is a single export button is clicked when products_excelExport function is called. For your convenience, I modified the sample and attached it to this thread.
I hope this information helps.
Regards,
Kostadin
Telerik by Progress
You can achieve that by using a single button to export the multiple grid and a single button to export only one grid. The multiple grid exporting is demonstrated in the provided sample and you can use the following code to export only a single grid.
$(
"#exportSingle"
).click(
function
() {
singleExport =
true
;
$(
"#products"
).data(
"kendoGrid"
).saveAsExcel();
});
Keep in mind you need to check is a single export button is clicked when products_excelExport function is called. For your convenience, I modified the sample and attached it to this thread.
I hope this information helps.
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.