View Single Post
  #1 (permalink)  
Old September 10th, 2007, 01:51 AM
zaghmout zaghmout is offline
Friend of Wrox
 
Join Date: Aug 2006
Location: Amman, , Jordan.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with exporting

Guys I have the following scenario hope anyone can help me with:
custom inquiry pages that generate a sql script, and afterwards i send the script to a page that reads the script, creates the dataset, binds it to a gridview, and exports it to an excel sheet, the data contains some Arabic characters, and when viewing in the gridview it self everything seems fine, but when exporting to excel, all the Arabic data is shown as a garbage! the data is stored in a NVarchar fields and i checked it in my database. I tried changing fonts but it did not work, my only explanation is that I must export to excel using Unicode. so how can I do that?

The following is the code I use in exporting to excel:

************************************************** *******
           Response.Clear()Response.AddHeader("content-disposition", "attachment;filename=" & strReportName & ".xls")
            Response.Charset = ""
            Response.ContentType = "application/vnd.xls"

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

            GridView1.RenderControl(htmlWrite)

            Response.Write(stringWrite.ToString())
            Response.End()
************************************************** *********

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
__________________
Nothing is impossible. The impossible only takes longer. \"Digital Fortress, Dan Brown\"