数据格式问题。 GridView中导出到Excel [英] Data format issue. Export GridView to Excel
问题描述
有是在GridView的字符串(1008901023816550000000)莫名其妙地被保存为Excel中的科学数字(1.0089E + 21)当我出口在GridView到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.
我使用.NET 4.0。
I am using .Net 4.0.
下面是我尝试过,但他们并没有解决问题:
Here is what I tried, but they didn't solve the problem:
- 新增DataFormatString ={0:绿}的绑定列标记
-
设置样式的RenderControl被称为后。
- Added DataFormatString="{0:g}" to the BoundColumn tag.
Set the style after the RenderControl was called.
字符串风格= @的.text {MSO的数字格式:\\ @;};
string style = @" .text { mso-number-format:\@; } ";
任何人都可以提供一些线索对这个问题的?
Can anyone shed some light on this problem?
推荐答案
presuming您使用CSV文件执行导出:
Presuming you are using a CSV file to perform the export:
这是Excel的一个怪癖,很难撼动。我所知道的唯一的想法是使用CSV文件中像这样的格式来试试:
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.
这篇关于数据格式问题。 GridView中导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!