PC Review


Reply
Thread Tools Rate Thread

Charset problem (dataset to excel)

 
 
Morten Snedker
Guest
Posts: n/a
 
      25th Jan 2007
The code below is used to get the content of a dataset to Excel and it
works quite okay, except:

Special Danish charachters look crappy when shown in Excel. Any ideas
if the problem can be solved?

response.Clear()
response.Charset = "iso-8859-2"
response.ContentType = "application/vnd.ms-excel"

Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)

Dim dg As New DataGrid
dg.DataSource = ds.Tables(0)
dg.DataBind()
dg.RenderControl(htmlWrite)

response.Write(stringWrite.ToString)
response.End()


Regards /Snedker
--
http://www.dbconsult.dk
http://www.vinthervej2.dk [private]
 
Reply With Quote
 
 
 
 
Joerg Jooss
Guest
Posts: n/a
 
      25th Jan 2007
Thus wrote Morten Snedker morten_spammenot_ATdbconsult.dk,

> The code below is used to get the content of a dataset to Excel and it
> works quite okay, except:
>
> Special Danish charachters look crappy when shown in Excel. Any ideas
> if the problem can be solved?
>
> response.Clear()
> response.Charset = "iso-8859-2"


Don't use HttpResponse.Charset -- that has no effect on the actual encoding
being used (it just sets an attribute of the Content-Type header). Instead,
use

Response.ContentEncoding = Encoding.GetEncoding("iso-8859-2");

which also sets HttpResponse.Charset implicitly.

Cheers,
--
Joerg Jooss
news-(E-Mail Removed)


 
Reply With Quote
 
Morten Snedker
Guest
Posts: n/a
 
      25th Jan 2007
On Thu, 25 Jan 2007 21:08:12 +0000 (UTC), Joerg Jooss
<news-(E-Mail Removed)> wrote:

Can I call you honey? :-)

Just changed to iso-8859-1 and all is well. Thanks a bunch for the
iceing on the cake!

/Regards

>use
>Response.ContentEncoding = Encoding.GetEncoding("iso-8859-2");
>which also sets HttpResponse.Charset implicitly.


--
http://www.dbconsult.dk
http://www.vinthervej2.dk [private]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unicode charset missing in charset list in outlook ariva Microsoft Outlook Discussion 0 8th Sep 2009 08:25 PM
charset problem MK Windows Vista Mail 1 14th Feb 2009 10:06 PM
DataSet and charset coding. Mad One Microsoft ADO .NET 1 29th Oct 2004 02:14 PM
charset problem Krzysiek Microsoft VB .NET 1 15th Jun 2004 12:49 PM
excel font charset moran Microsoft Excel Misc 0 16th Jul 2003 10:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 PM.