Strange characters - help needed

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.
 
G

Guest

The code you supplied does not help identify the problem.

We do not know what type "Response" is.
 
J

Jon Skeet [C# MVP]

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top