Export Gridview data to Excel (.xlsx) without using HtmlTextWriter in Asp.NET

You can use export data by using EPPlus.dll. Following is the sample code. public void ExportToExcel(){DataView dv = new DataView();System.Data.DataTable tbl = new System.Data.DataTable();dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); // To access the data associated with Gridviewtbl = dv.ToTable(); //Following code is copied from StackOverFlow using (ExcelPackage pck = new ExcelPackage()){//Create the worksheetExcelWorksheet ws = pck.Workbook.Worksheets.Add(“Demo”); //Load the datatable into […]