Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trying to stream back data into Excel from ASP.NET - charset issue

Folks,

we're trying to stream back a result set from a SQL query into Excel
from our ASP.NET application.

Basically, we're doing this he

Response.ContentType = "text/csv";
Response.Charset = "utf-8";

Response.AddHeader("Content-Disposition", "attachment;
filename=data.csv");

Response.Write(sb.ToString());
Response.End();

"sb" is our StringBuilder object which contains the data we're
streaming back.

The trouble is: we have German, French and Italian special characters
in the response, stuff like German umlauts (ä ö ü) and French accents
(é è à and so forth).

When Excel (both 2003 and 2007) pops up, it reads in the contents of
the CSV stream, but it mangles the special characters. It almost looks
as if Excel insists on interpreting this as ANSI / "Windows-1252" /
ISO-8859-1 characters (even though I *specifically* told it that the
response had a "utf-8" charset) and fails to get the special ones
right....

I end up with stuff like Zürich instead of Zürich or Genève instead
of Genève and so forth.

Funny thing: if I choose to SAVE the resulting CSV file, and then open
it in Excel, I get the text file import wizard and I'm able to pick
the encoding - setting it to UTF-8 gives me the desired results.

On the other hand, if I save the file and then double-click it, I get
the same results as when opening the result stream directly - no
wizard, no way of specifying the encoding, and Excel just assuming
"ANSI" and screws up the special characters....

Any ideas or ways to get around this?? I'm totally baffled that
something as widely used as Excel has such trouble handling UTF-8
files and the special chars inside them!

Thanks for any help or pointers

Marc
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bloomberg overwrites data-need to save stream of data in a new she Melanie Excel Worksheet Functions 2 December 27th 07 05:42 PM
Open an excel from a .NET stream AL Excel Programming 0 January 25th 07 11:17 AM
Use META tag to specify the charset on a HTML table, all cells are treated as text in Excel 2003 [email protected] Excel Programming 0 May 31st 06 09:26 PM
Data Stream Converter ?? Dan Thompson[_2_] Excel Programming 0 February 22nd 05 06:51 PM
Need help trying to open a file and stream data into a sheet... Susan Hayes Excel Programming 2 August 9th 04 11:10 PM


All times are GMT +1. The time now is 08:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"