The Angular Grid provides options for exporting its data to Excel.
To enable the Excel export, import the ExcelModule and add the kendo-grid-excel component to the Kendo UI Grid for Angular. To initiate the export, use the kendoGridExcelCommand directive or the saveAsExcel method.
With regard to its Excel export, the Grid enables you to:
By default, the Grid exports its current data. To export data that is different from the current Grid data, specify a custom fetchData function. It returns an ExcelExportData value or array. The allData()
method takes a collection of data—typically, but not mandatory, the same collection to which the Grid is bound—processes it (for example, applies or removes paging, filtering, sorting, and so on), and uses the resulting object to create the workbook.
The following example demonstrates how to export all data when the content is split into pages.
If the export data needs to be asynchronously loaded, you can return an Observable
or a Promise
which will be resolved with the data that is exported.
When you export a Grid which contains a detail template to Excel, the content of the template is not exported in the generated Excel document. To export the template content to Excel, handle the excelExport event of the Kendo UI Grid for Angular and modify the created workbook so that the data for the detail Grids is integrated in the exported document.
The following example demonstrates how to perform the custom logic for retrieving the data for all detail Grids and append it to the original workbook.
By default, the Grid exports its current columns. To export columns that are different from the current Grid columns, include the <kendo-excelexport-column>
and <kendo-excelexport-column-group>
components inside the <kendo-grid-excel>
component.
The Excel export functionality is configured to work with the Grid data rather than with the cell's content. That is why the values in the exported sheet have no format applied.
To customize all cells in a given column, you can set the cellOptions property of the kendo-excelexport-column
component. To apply specific currency or percentage format, use the format option. For more details on the supported Excel formats, refer to the Microsoft Create a custom number format page.
The following example demonstrates how to format the cells in the exported Excel document.
The excelExport event allows you to customize the generated Excel document. The workbook event argument exposes the generated Excel workbook configuration.
The Grid enables you to trigger the export operation by calling the saveAsExcel method.
The collapsible option allows you to create a collapsible outline for each group.