# Exporting Filtered Data to Excel File by Using the Angular Data Grid

## Environment

<table>
	<tbody>
		<tr>
			<td>Product</td>
			<td>Progress® Kendo UI® Data Grid for Angular</td>
		</tr>
	</tbody>
</table>

## Description

How can I export the filtered data to an Excel file by using the Angular Data Grid?

## Solution

By default, the Grid exports the current data. To export specific data to Excel:

1. Specify a custom [`fetchData`](https://www.telerik.com/kendo-angular-ui/components/grid/api/excelcomponent#fetchdata) callback function for the `<kendo-grid-excel>` component. The `fetchData` callback returns an [`ExcelExportData`](https://www.telerik.com/kendo-angular-ui/components/excel-export/api/excelexportdata) value or an array collection. This is the data exported to the Excel file.

   ```html
   <kendo-grid-excel ... [fetchData]="filteredData" ></kendo-grid-excel>
   ```

2. To export only the filtered data, apply the [`State`](https://www.telerik.com/kendo-angular-ui/components/data-query/api/state) of the Grid and return the modified collection.

   ```ts
   public state: State = {
       filter: {
         logic: 'or',
         filters: [
             { field: 'ProductName', operator: 'contains', value: 'Cha' }
       ]}
   };

   public filteredData(): ExcelExportData {
       const result: ExcelExportData = {
           data: process(products, this.state).data,
       };
       return result;
   }
   ```

The following example demonstrates how to export only the filtered rows to Excel.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/grid-export-filtered-data-excel/source.txt)

## See Also

[How to export all Grid data to Excel](https://www.telerik.com/kendo-angular-ui/components/grid/export/excel-export#controlling-the-exported-data)
