string datestyle = @"<style> .nf{mso-number-format:\@;}</style>";
MainGridView.Visible = true;
MainGridView.ForeColor = System.Drawing.Color.Black;
MainGridView.AllowPaging = false;
MainGridView.DataSource = Session["objListRechargeDTO"];
MainGridView.DataBind();
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=OneCardTransactionReport.xls");
Response.Charset = "";
Response.ContentType = "application/xls";
System.IO.StringWriter WriteItem = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlText = new HtmlTextWriter(WriteItem);
MainGridView.HeaderRow.Style.Add("background-color", "#CCCCCC");
MainGridView.HeaderRow.Style.Add("background-color", "#CCCCCC");
// MainGridView.Columns[2].Style.Add("Color","#000000");
MainGridView.Columns[0].Visible = false;
MainGridView.Columns[13].Visible = false;
MainGridView.Columns[14].Visible = false;
for (int i = 0; i < MainGridView.Rows.Count; i++)
{
HyperLink hl = (HyperLink)MainGridView.Rows[i].FindControl("hl");
hl.NavigateUrl = "";
HyperLink custemail = (HyperLink)MainGridView.Rows[i].FindControl("custemail");
custemail.NavigateUrl = "";
}
Response.Write(datestyle);
MainGridView.AllowPaging = false;
MainGridView.RenderControl(htmlText);
Response.Write(WriteItem.ToString());
// Response.BinaryWrite((byte[])command.ExecuteScalar());
Response.End();