Advertisement

05.24.2007 at 01:19PM PDT, ID: 22593520
[x]
Attachment Details

how to stream UTF-8 characters to excel

Asked by dready in Microsoft Visual C#.Net, Microsoft Excel Spreadsheet Software, .NET Framework 2.0

Tags: excel

Hi,

from the data in my asp.net application i want to generate a excel file for the user to download. I generate it first using a stringbuilder sb, and then use the following code to stream a xls file to the user.
All works fine, but if the user types in special characters like ö, ô, ä, etc, they appear like  sth like this: öò
In the stringbuilder that i use, the characters are still in the correct form. So the problem must lie in this piece of code: (response is a object of type System.Web.HttpResponse)

response.Clear();
response.ContentType = "application/vnd.ms-excel";
response.Charset = "";
response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", FileName));
response.Write(sb.ToString());
response.Flush();
response.End();

I tried using
response.Charset = "utf-8";
or
response.ContentType = "application/vnd.ms-excel;charset=UTF-8";

but that didnt help. How can i get the UTF-8 characters in excel?Start Free Trial
[+][-]05.24.2007 at 07:28PM PDT, ID: 19154407

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, Microsoft Excel Spreadsheet Software, .NET Framework 2.0
Tags: excel
Sign Up Now!
Solution Provided By: SegFault
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32