public ActionResult ExportTable(string sql, string dbName, string connectionStringName = "SqlServerHelper") { DataAccess.SelectTableAccess access = new DataAccess.SelectTableAccess(); var dy = access.Select(sql, dbName, connectionStringName); string path = Server.MapPath(@"~/App_Data/Export/export.xls"); bool result = ExcelExport.ExportExcelWithAspose(dy, path); return(File(path, "application/ms-excel", "export.xls")); }