private void ExportGridView()
{
System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
gvFiles.RenderControl(htw);
string renderedGridView = sw.ToString();
File.WriteAllText(@"C:\Path\On\Server\ExportedFile.xlsx", renderedGridView); }