How do we prevent from scientific notation when exporting SQL Server data into an Excel sheet.
A 20 digit column value gets convert into scientific notation instead of the exact value. e.g. in SQL Server the value is 31812121800006173492.
But when I export the data into Excel, the value gets turn into the 3.18121E+19.
How do I get the exact value in Excel?
I have written the below code for export the data into the excel: Please suggest where and how do we set style attribute.
string filename = filename + "COC Report" + ".xls";
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid dgGrid = new DataGrid();
dgGrid.DataSource = dsexcel;
dgGrid.DataBind();
dgGrid.ShowHeader = true;
dgGrid.CellPadding = 2;
dgGrid.CellSpacing = 2;
dgGrid.RenderControl(hw);
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
this.EnableViewState = false;
Response.Write(tw.ToString());
Response.End();