try this
protected void Export_to_Excel_Click(object sender, EventArgs e)
{
try
{
GridView gv = new GridView();
Grd_MidData.AllowPaging = false;
BindCustomersDDL();
gv = Grd_MidData;
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
for (int i = 0; i < Grd_MidData.HeaderRow.Cells.Count; i++)
gv.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
int[] columnsToBeHidden = { 2,8 };
for (int i = 0; i < columnsToBeHidden.Length; i++)
gv.Columns[i].Visible = false;
gv.RenderControl(htw);
Response.Write(sw.ToString());
Response.Flush();
}
catch (Exception ee)
{
}
}
Pass the index of the column which you want to hide
int[] columnsToBeHidden = { 5,6};