Export datagrid to excel file

A

Amirallia

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 ?
 
J

John Timney \(MVP\)

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)
 
A

Amirallia

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)

Thanks, but it doesn't work !

But what do you mean when you write: charcater encoding type along with
your application
 
G

Guest

charset=windows-1251 is character charcater encoding type

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Export datagrid to Excel with a lot of rows 2
Export To Excel 1
Export to Excel 1
export dataset to excel 5
Export datagrid to excel 1
export to excel 0
IE unable to open Excel stream 1
export to excel 1

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top