New to Kendo UI for Angular? Start a free 30-day trial

Exporting Multiple Data Sets to Separate Excel Sheets

Environment

ProductProgress® Kendo UI for Angular Excel Export

Description

How can I export multiple data sets to individual workbook sheets in the Kendo UI for Angular Excel Export?

Solution

You can obtain references to the respective ExcelExport components and use custom logic to merge the individually generated workbooks of the separate components into one.

  1. Obtain references to the respective ExcelExport components by using the template reference variables or, for example, ViewChild.

  2. Merge the generated workbook sheets into one and export their content by using the save() method.

    public save(component1, component2): void {
        Promise.all([component1.workbookOptions(), component2.workbookOptions()]).then((workbooks) => {
            workbooks[0].sheets = workbooks[0].sheets.concat(workbooks[1].sheets);
            component1.save(workbooks[0]);
        });
    }

The following example demonstrates the full implementation of the suggested approach.

Example
View Source
Change Theme:

When the number of datasets that will be exported to a separate sheet is not known in advance, you can extend the suggested approach to create multiple ExcelExport components over *ngFor and map them to a collection of WorkbookOptions that can be exported to a single file with separate sheets.

Example
View Source
Change Theme:

In this article

Not finding the help you need?