Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 10th, 2007, 01:51 AM
Friend of Wrox
 
Join Date: Aug 2006
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\"
 
Old September 11th, 2007, 08:00 AM
Friend of Wrox
 
Join Date: Aug 2006
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"
 
Old September 11th, 2007, 08:14 AM
Wrox Author
 
Join Date: Oct 2005
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

================================================== =========
 
Old September 12th, 2007, 01:01 AM
Friend of Wrox
 
Join Date: Aug 2006
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"
 
Old September 12th, 2007, 04:07 AM
Friend of Wrox
 
Join Date: Aug 2006
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"





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem exporting to excel neversummer84 Classic ASP Databases 1 June 15th, 2006 12: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 08: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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.