Gridview to XLS... formatting issues

N

Not Me

Hi, I use the following code to export a prepared gridview control as an
excel spreadsheet.

***
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False

Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

Dim frm As HtmlForm = New HtmlForm()
Me.Controls.Add(frm)
frm.Controls.Add(gvSearch)

frm.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
***

Now it all works great, however in the gridview I have some text fields
which feature leading 0s. When exported, excel decides they should be
stored as numbers, and therefore the leading 0s are gone.

What's the best way to avoid this? more code in the above, or altering
the data in the gridview?

Cheers for any help,
Chris
 
S

sloan

I know this answer stinks...but I remember this problem from like 2 years
ago.

I ended up having to put a "@" in front of the number.

Yeah, that solution stinks.

...
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top