Strange characters - help needed

  • Thread starter Thread starter Code Monkey
  • Start date Start date
C

Code Monkey

I'm exporting the contents of a GridView (in C# v2) into Excel.

However, whilst the GridView displays on the web page correctly, when
the data is in Excel, I get a lot of  characters appearing ('A' with
a hat on top) where there are numbers (ie; order numbers and line
totals).

Is there an easy way to remove these?
The code I'm using looks like:


<code>
protected void btn_export_Click(object sender, EventArgs e)
{
Response.Clear();
String fileName = Invoice";
Response.AddHeader("content-disposition",
string.Format("attachment;filename={0}.xls", fileName));
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
Response.Write(sb.ToString());
Response.Write(Session["ExcelDataGrid"].ToString());
Response.End();
}
</code>

and I've got
<code>
<globalization requestEncoding="utf-8" responseEncoding="utf-8"
culture="en-GB"/>
</code>

in my web.config file.
 
The code you supplied does not help identify the problem.

We do not know what type "Response" is.
 
Code Monkey said:
I'm exporting the contents of a GridView (in C# v2) into Excel.

However, whilst the GridView displays on the web page correctly, when
the data is in Excel, I get a lot of  characters appearing ('A' with
a hat on top) where there are numbers (ie; order numbers and line
totals).

Is there an easy way to remove these?

I believe the problem is that you're writing it as a *string* - Excel
spreadsheets aren't typically text data. Open one in Notepad...
 
Back
Top