Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2006

Tip: Looking for answers? Try searching our database.

Encoding issue..

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
elangovan.cse@gmail.com - 29 Sep 2006 09:48 GMT
Hi all,
I'm exporting a datagrid to an excel file.
I'm using the following source code to export
DataTable dt = new DataTable();

            DataAccess.StoredProcedure sproc = new
DataAccess.StoredProcedure("sproc_getdata");
            sproc.Run(dt);
            DataGrid1.DataSource = dt;
            DataGrid1.DataBind();
            DataGrid1.EnableViewState = false;
            DataGrid1.Visible = true;
            DataGrid1.GridLines = GridLines.Both;
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader( "Content-Disposition", "filename=File1.xls");

            StringWriter stringWriter = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
            DataGrid1.RenderControl(htmlWriter);
            Response.Write(stringWriter.ToString());
            Response.ContentType="application/vnd.ms-excel";
            Response.End();

Its working fine.
but there is an isuue datagrid contains  extended language
strings(like chinese, japanese).These stringsare not getting exported
into excel.
DataGrid is getting data from SQLServer2005 database. I know that
sqlserver is using utf-16 encoding for unicode character. So i've tried
to change Response.ContentEncoding to utf-16. But it is also not
working.

Can anyone help me.
Jon Skeet [C# MVP] - 30 Sep 2006 08:16 GMT
<snip>

>  Its working fine.
>  but there is an isuue datagrid contains  extended language
[quoted text clipped - 6 lines]
>  
> Can anyone help me.

See http://www.pobox.com/~skeet/csharp/debuggingunicode.html for a
short guide to solving this kind of issue.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.