I'm trying to export Gridview to Excel file.
Example SQL Database Record
91091234 SAM PLE TEXT
89237416 SAMPLE TEXT
I've been able to bind it to Gridview including the multiple spaces. I've used this code to include those multiple spaces
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (TableCell cell in e.Row.Cells)
{
cell.Text = cell.Text.Replace(" ", " "); // need to modify this part, i think
}
}
My code for exporting Gridview to Excel
private void _exportGV()
{
Response.Clear();
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
string FileName = "Instances" + ".xls";
StringWriter strwritter = new StringWriter();
HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
gv.GridLines = GridLines.Both;
gv.HeaderStyle.Font.Bold = true;
gv.RenderControl(htmltextwrtter);
Response.Write(strwritter.ToString());
Response.End();
}
So my problem is when I export the data shows like this
91091234 SAM PLE TEXT
89237416 SAMPLE TEXT
How do I retain the multiple spaces without replacing it to  ?