Hello Neha,
For exporting data into Excel follow the below link and follow the steps mentioned in that, you will get a solution for your exporting data into excel.
https://academy.mendix.com/link/module/136/lecture/1252/7.1-Using-the-Excel-Exporter-to-Export-Data
Hope this helps you.
You can export to an excel or csv directly from the datagrid. That option is available if your datagrid has XPath as datasource. See for more info: https://docs.mendix.com/refguide8/control-bar#export-to-excel-button
If a webpage with a grid is not an option and you need to download it from a microflow, then there is OQL. The quick start: Download module OQL and create a microflow that uses “ACT_ExecuteOQL” with as value for its parameter ‘Query’ a basic OQL as string:
from MyFirstModule.MyEntity select *