Data format issue. Export GridView to Excel
There was a string (1008901023816550000000)
in the GridView somehow was saved as a scientific number (1.0089E+21)
in Excel when I exported the GridView to Excel.
I am using .Net 4.0.
Here is what I tried, but they didn't solve the problem:
- Added
DataFormatString="{0:g}"
to theBoundColumn
tag. - Set the
style
after theRenderControl
was called.
string style = @"<style> .text { mso-number-format:\@; } </scr开发者_如何学Pythonipt> ";
Can anyone shed some light on this problem?
Try This, It will work.
string style = @"<style> TD { mso-number-format:\@; } </style> ";
Presuming you are using a CSV file to perform the export:
This is a quirk of Excel that's hard to shake. The only idea I know of is to try using a format like this inside the CSV file:
="1008901023816550000000"
This will force it to be a formula that returns the desired text.
精彩评论