Click here to Skip to main content
11,705,762 members (46,538 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Excel Gridview
StringWriter strWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(strWriter);
 
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=excel.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";

i used above code to convert my gridview to excel, everything is good except one field which contains up to 12 numbers.
they look good in gridview, after convert to excel, it became:
   Gridview        Excel
860201231356 to 8.60201E+11
123456121115 to 1.23456E+11
123456120010 to 1.23456E+11
i need to manually
1. Change the format from text to number
2. Press "Decrease decimal" to remove the ".00"

if there anyway to solve this?
Posted 17-Apr-13 23:00pm
melvintcs1.1K

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I think you will have to result to using Interop for this, as it gives much more flexibility to define the cell type in Excel:
http://support.microsoft.com/kb/302084[^]

I dont think it is possible using other techniques but they might be..
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 170
2 Inimicos 60
3 ProgramFOX 50
4 F-ES Sitecore 45
0 OriginalGriff 9,037
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100