开发者

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:

  1. Added DataFormatString="{0:g}" to the BoundColumn tag.
  2. Set the style after the RenderControl 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜