public void ExportToExcel(string filterNombre, string filterApellidos, string filterTipoTitulacion, string filterTipoIdentificacion, string filterNumeroIdentificacion, string filterTipoTecnologia, string filterCentro, string filterEmail, string filterTelefono, string filterCentroEducativoId, string filterAnioRegresado, string filterNivelIdioma) { IDictionary <string, string> CustomFilters = new Dictionary <string, string> { { "Nombre", filterNombre }, { "Apellidos", filterApellidos }, { "TipoTitulacion", filterTipoTitulacion }, { "TipoIdentificacion", filterTipoIdentificacion }, { "NumeroIdentificacion", filterNumeroIdentificacion }, { "TipoTecnologia", filterTipoTecnologia }, { "CentroSearch", filterCentro }, { "Email", filterEmail }, { "Telefono", filterTelefono }, { "CentroEducativoId", filterCentroEducativoId }, { "AnioRegresado", filterAnioRegresado }, { "NivelIdioma", filterNivelIdioma } }; var request = new DataTableRequest { CustomFilters = CustomFilters }; var response = _candidatoService.GetCandidatosExportToExcel(request); var grid = new System.Web.UI.WebControls.GridView { DataSource = response.CandidatoRowExportToExcelViewModel }; grid.DataBind(); Response.ClearContent(); string filename = string.Format("Listado_de_Candidatos_{0}", DateTime.Now.ToShortDateString() + ".xls"); Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", filename)); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); grid.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); }