I got the data from database into my dataset is
and then i bind into my repeater control but its is been showing like “Prince Antony G”. It eliminated the Spaces.
and also i export those data into excel, In excel also the spaces were removed.
I need the show data whatever in my Database. Any idea to solve this problem.
In stack overflow Question box also remove more spaces in between two words
My Excel Coding:
DataTable dt = new DataTable("Report");
DataRow dr;
dt.Columns.Add("Name");
for (int i = 0; i < dt_Status.Rows.Count; i++)
{
dr = dt.NewRow();
dr["Name"] ="<pre>"+ dt_Status.Rows[i]["NAME"].ToString() +"</pre>";
dt.Rows.Add(dr);
}
HttpResponse response = HttpContext.Current.Response;
// first let's clean up the response.object
response.Clear();
response.Charset = "";
// set the response mime type for excel
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=Report.xls");
// create a string writer
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
// instantiate a datagrid
DataGrid dg = new DataGrid();
dg.DataSource = dt;
dg.DataBind();
dg.RenderControl(htw);
response.Write(sw.ToString());
response.End();
}
}
After updating my code i got the excel output as:

I need to display in a single cell.
html doesn’t recognize multiple spaces.
You you put your data between
<pre></pre>tags to say that is is per-formatted.Or you could replace the space with
. This is a non breaking space character.Space is used for formatting your html code, and hence if you have more than one space, it gets wrapped to just one.