Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 10th, 2007, 02:51 AM
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\"
  #2 (permalink)  
Old September 11th, 2007, 09:00 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Amman, , Jordan.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Guys I really need an answer here..... i can't find anything online and I tried everything!!





Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
  #3 (permalink)  
Old September 11th, 2007, 09:14 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I have no experience working with Arabic characters so I can not give you any first hand advice, however this guys blog post looked promising:

http://moustafa-arafa.blogspot.com/2...t-data-to.html

Make sure to read his last comment in his blog comments about his response from the VS Team.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
  #4 (permalink)  
Old September 12th, 2007, 02:01 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Amman, , Jordan.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

tnx a lot man, I viewed the site and I'll try it now

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
  #5 (permalink)  
Old September 12th, 2007, 05:07 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Amman, , Jordan.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok after reading the post, I updated my code to :

************************************************** **********
           Response.Clear()
            Response.Buffer = True
            Response.Charset = "" 'You can set UTF-8 or windows-1256 but this will not solve
            Response.AddHeader("content-disposition", "attachment;filename=" & strReportName & ".xls")
            Response.ContentType = "application/vnd.ms-excel"
            Me.EnableViewState = False
            Dim stringWrite As New System.IO.StringWriter()
            Dim htmlWrite As New HtmlTextWriter(stringWrite)

            GridView1.RenderControl(htmlWrite)


            'Response.OutputStream.Write(byte(){0xef, 0xbb, 0xbf}, 0, 3)
            Response.OutputStream.Write(New Byte() {239, 187, 191}, 0, 3)

            Response.Write(stringWrite.ToString())
            Response.Flush()
            HttpContext.Current.ApplicationInstance.CompleteRe quest()
************************************************** **********

but this code solved my problem in office 2003, but I still have a problem with the office 2000 :s

guys any suggestions?




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


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem exporting to excel neversummer84 Classic ASP Databases 1 June 15th, 2006 01:55 PM
Problem while exporting. rupen Classic ASP Professional 5 March 6th, 2006 04:38 PM
Problem Exporting Data... mat41 SQL Server 2000 1 September 29th, 2005 09:35 PM
problem exporting datagrid to excel kscdave Classic ASP Professional 0 March 29th, 2005 11:57 AM
Problem in exporting data to PDF vasansrini Crystal Reports 1 December 10th, 2004 11:48 AM



All times are GMT -4. The time now is 05:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.