Jui Test February 2016

Export gridview to csv

I am trying export gridview to csv.

  • I am adding actual record into cell of excel not trying html to excel.
  • I am executing sp, taking record into datatable.
  • Looping through datatable, writing into file using streamwriter.

But problem occur when my column has long number, csv shows 890+32 like this.

I don't want like this, want actual number like 89012345676898899998776766544333445556677.

How to do that? I am not using Gridview.RenderControl(htmltextwrtter).

Answers


print x div 0 February 2016

Try to cast the number into a String and add a leading ' to force excel to see the entry as text, like this:

'89012345676898899998776766544333445556677

Otherwise excel will see them as numbers (which they are, of course) and auto-format them in the unwanted format.

Post Status

Asked in February 2016
Viewed 1,654 times
Voted 14
Answered 1 times

Search




Leave an answer