Export data to Excel file with MVC C#
Most of the time it is required to export data into Excel file in Application. So i have tried many ways but i found very simple code for that. Sometime we need to hit by ajax call sometimes direct action link. so personally i like direct hit we don't need to redirect anywhere on button click. i have use this code to export excel file in mvc. let's go through the code. So on controller level we have to define one method look like- now you can see here i have defined void type method not ActionResult. ///controller Action Method public void ExportExcel() { Export export = new Export(); export.ExcelExportMethod(Response); } Second we have to create class by Export name and under class create one method looks like- public void ExcelExportMethod(HttpResponseBase Response) { var grid = new System.Web.UI.WebControls.GridView(); grid.DataSource = //need to pass Data in list type...