Datagrid exportation to MS-Excel

G

Guest

I am using the following funtion to export datagrids to xls:
Public Shared Sub Exportar(ByVal dg As DataGrid)

Dim g As New Guid
Dim oResponse As System.Web.HttpResponse =
System.Web.HttpContext.Current.Response
oResponse.Clear()
oResponse.AddHeader("Content-Disposition", "attachment;
filename=Exportador" + g.NewGuid.ToString + ".xls")
oResponse.ContentType = "application/vnd.ms-excel"
oResponse.ContentEncoding = System.Text.Encoding.Default


Dim stringWrite As New System.IO.StringWriter


Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
dg.RenderControl(htmlWrite)
oResponse.Write(stringWrite.ToString)
oResponse.Flush()
oResponse.Clear()
oResponse.Close()

HttpContext.Current.ApplicationInstance.CompleteRequest()

It works ok, but I have a problem with number formatting:
.. The datagrids use space as grouping char and dot as decimal char, like
this:
### ### ### 0.0
.. The number regional settings of the clients in IE6 on windows 2000 also
use these formats

The problem is that excell does not recognise the output as a number, I
think it's because of the spaces.
.. Do the regional settings of the webserver matter?
.. Is the rendering to HTML of number formatting in datagrids is always done
the same way regardless of the regional settings of Server/Clients, or it
depends on it? how does this work?
.. Is there any solution for the correct exportation to xls?


Thanks in advance
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top