Problem to Export in Excel data format

A

Alessandro

Hi !
I have a table on an aspx page and i want to export its rows into an Excel
File, the script is

Page.Response.Clear()
Page.Response.ClearContent()
Page.Response.ClearHeaders()

Me.TBLexcel.RenderControl(oHTMLWriter)
Page.Response.Write("<html><head></head><body>")
Page.Response.Write(oStringWriter)
Page.Response.Write("</body></html>")
Response.charset="utf-8"
Dim OpenType As String = "attachment"
Page.Response.ContentType = "application/ms-excel"
Page.Response.AddHeader("Content-Disposition", OpenType + ";filename="
+FileName)
Page.Response.End()


But, if i open the file with notepad i find= Members of community Facoltà
di Economia
if i open the file with excel i find= Members of community Facoltà di
Economia


so, there is a problem with encoding, but i don't understand where !
 
A

Alessandro

The complete code:


Dim FileName As String = "Iscritti.xls"
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHTMLWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
Page.Response.Clear()

Me.TBLexcel.RenderControl(oHTMLWriter)
Dim OpenType As String = "attachment"
Page.Response.ContentType = "application/ms-excel"
Page.Response.AddHeader("Content-Disposition", OpenType + ";filename=" +
FileName)
Page.Response.Write(oStringWriter)
Page.Response.End()


The problem is with object "oStringWriter ",it uses unicode and not UTF-8,
but it's not possible to change this encoding
 

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


Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,087
Latest member
JeremyMedl

Latest Threads

Top