Column Formatting When Exporting to Excel

J

John Walker

Hi,

In asp.net 2.0 I am exporting a gridview to excel using this code:

Dim resp As HttpResponse
resp = Page.Response
resp.ContentType = "application/download"
Page.EnableViewState = False
resp.Charset = String.Empty
resp.AppendHeader("Content-Disposition",
"attachment;filename=Report.xls")

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

gv.AllowPaging = False
gv.RenderControl(hw)

But once in excel some of the numeric values in a text column are being
displayed with some sort of shorthand. An example is 145899325676 gets
changed to 1.45899E+11. Is there a way to format that column
programmatically to text before exporting so that the data is not manipulated?

Thanks,
John
 

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,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top