473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Export datagrid to excel file

Hello

Here is my code to export a datagrid to Excel, it's work but the no
ASCII caracter are not correctly exported (for example : caracter "é"
)

Response.Clear()
Response.Buffer = True

Response.AddHeader("content-disposition",
"attachment;filename=Final.xls")
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = "UTF-8"

Dim monStringWriter As System.IO.StringWriter = New
System.IO.StringWriter
Dim monHtmlTextWriter As HtmlTextWriter = New
HtmlTextWriter(monStringWriter)
Me.dg1.RenderControl(monHtmlTextWriter)
Response.Write(monStringWriter.ToString())
Response.End()

Any idea to export correctly ?
Jul 25 '06 #1
3 5337
I believe you need to set your charcater encoding type along with yuor
application. Its something like this but you'll need to dig about to get it
right.

Response.ContentType = "application/vnd.ms-excel;charset=windows-1251"

Regards

John Timney (MVP)
"Amirallia" <bn**@bluewin.chwrote in message
news:mn***********************@bluewin.ch...
Hello

Here is my code to export a datagrid to Excel, it's work but the no ASCII
caracter are not correctly exported (for example : caracter "é" )

Response.Clear()
Response.Buffer = True

Response.AddHeader("content-disposition", "attachment;filename=Final.xls")
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = "UTF-8"

Dim monStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim monHtmlTextWriter As HtmlTextWriter = New
HtmlTextWriter(monStringWriter)
Me.dg1.RenderControl(monHtmlTextWriter)
Response.Write(monStringWriter.ToString())
Response.End()

Any idea to export correctly ?


Jul 25 '06 #2
John Timney (MVP) avait prétendu :
I believe you need to set your charcater encoding type along with yuor
application. Its something like this but you'll need to dig about to get it
right.

Response.ContentType = "application/vnd.ms-excel;charset=windows-1251"

Regards

John Timney (MVP)
"Amirallia" <bn**@bluewin.chwrote in message
news:mn***********************@bluewin.ch...
>Hello

Here is my code to export a datagrid to Excel, it's work but the no ASCII
caracter are not correctly exported (for example : caracter "é" )

Response.Clear()
Response.Buffer = True

Response.AddHeader("content-disposition", "attachment;filename=Final.xls")
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = "UTF-8"

Dim monStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim monHtmlTextWriter As HtmlTextWriter = New
HtmlTextWriter(monStringWriter)
Me.dg1.RenderControl(monHtmlTextWriter)
Response.Write(monStringWriter.ToString())
Response.End()

Any idea to export correctly ?

Thanks, but it doesn't work !

But what do you mean when you write: charcater encoding type along with
your application
Jul 25 '06 #3
charset=windows-1251 is character charcater encoding type

application/vnd.ms-excel;charset=windows-1251 is charcater encoding type
along with your application

"Amirallia" wrote:
John Timney (MVP) avait prétendu :
I believe you need to set your charcater encoding type along with yuor
application. Its something like this but you'll need to dig about to get it
right.

Response.ContentType = "application/vnd.ms-excel;charset=windows-1251"

Regards

John Timney (MVP)
"Amirallia" <bn**@bluewin.chwrote in message
news:mn***********************@bluewin.ch...
Hello

Here is my code to export a datagrid to Excel, it's work but the no ASCII
caracter are not correctly exported (for example : caracter "é" )

Response.Clear()
Response.Buffer = True

Response.AddHeader("content-disposition", "attachment;filename=Final.xls")
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = "UTF-8"

Dim monStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim monHtmlTextWriter As HtmlTextWriter = New
HtmlTextWriter(monStringWriter)
Me.dg1.RenderControl(monHtmlTextWriter)
Response.Write(monStringWriter.ToString())
Response.End()

Any idea to export correctly ?


Thanks, but it doesn't work !

But what do you mean when you write: charcater encoding type along with
your application
Jul 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Eric | last post by:
Dear All, I want to export datagrid content to a Excel file, the code just like below: Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Me.EnableViewState = False Dim...
1
by: Diego | last post by:
Hi, I have a ASP.NET application and i'm interested in reporting in excel format. I read a good artile written by Steve C. Orr that gave me info about exporting to excel. ...
6
by: Sridhar | last post by:
Hi, I have to export data inside the datagrid into an excel worksheet. I have to do this on button click event. I am trying to do like this. First get the DataTable from the datagrid and...
2
by: Arvind R | last post by:
Hello, how to ask saveas dialog before writing the data to the excel file? right now im able to save in c drive or any other specified location only. any solution will be a great help! ...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
7
by: mattmerc | last post by:
Hi all, We have all seen lot of method for exporting datagrids to Excel. I have a slightly different need. I think it should be easy to accomplish but I am not sure how. I would like when a user...
3
by: ABC | last post by:
What methods can export excel file from stored procedure with parameters which input from web form?
4
by: Amirallia | last post by:
Hello Here's my code to export a datagrid to Exel : Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" Response.Charset = "" Dim monStringWriter As...
19
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services...
5
by: Reggie | last post by:
Hi and TIA! I have an export procedure that exports my data from my datagrids to excel. The problem is that I lose leading zero's cause excel removes them and doesn't treat them as text. Is it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.