Hi Every one,
I am filling Grid with some date(from database),and exporting into excel.After exporting in to excel, the value 07896542 shown as 7896542 i.e. left side zero trimming. Please help me, how can I format excel column while exporting to excel. see the following code.
Thanks in advance.
if (Excel == "YES")
{
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();
dgGrid = new DataGrid();
dgGrid.DataSource = dtinvoice;
dgGrid.HeaderStyle.Font.Bold = false;
dgGrid.DataBind();
dgGrid.RenderControl(hw);
Response.AddHeader("Content-Disposition", "attachment;filename=Executivereport.xls");
Response.ContentType = "application/vnd.ms-excel ;charset=utf-8";
Response.ContentEncoding = System.Text.Encoding.Unicode;
Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();
}