[转]html导出到excel数据格式不正确解决方法 html导出到excel数据格式不正确解决方法

  同事离职 ,把手头的程序给我了,第二天客户说:“为什么我们导出的excel不会自己汇总啊??”

。。。。您稍等一下,我看一下哈(我怎么知道你们导出的excel为什么不会汇总啊!!)

打开程序

[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法

没什么问题,然后导出打开

[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法

这是神马?合着你导出来的全部是文本格式的了。文本格式存储的数字怎么汇总你告诉我。

看代码吧

 View Code

excel的数据格式:gvExport.Attributes.Add("style", "vnd.ms-excel.numberformat:@");

下面是常用的一些格式: 
1)文本:vnd.ms-excel.numberformat:@   
2)日期:vnd.ms-excel.numberformat:yyyy/mm/dd  
3)数字:vnd.ms-excel.numberformat:#,##0.00  
4)货币:vnd.ms-excel.numberformat:¥#,##0.00  
5)百分比:vnd.ms-excel.numberformat: #0.00% 

你这里输出的格式就是文本啊!果断的改成第三条数字类型的(哈哈,我是不是很聪明)

[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法

等等,我表头的日期怎么回事,也变成数字了,看到它还有两位小数的就挠头了(失误,失误哈)

gvExport.HeaderRow.Attributes.Add("style", "[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法vnd.ms-excel.numberformat:@");    

gvExport.Attributes.Add("style", "[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法vnd.ms-excel.numberformat:#,##0.00");
把表头改成原来的就行了,咱也不去改成时间类型了。
[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法
ok!完美,perfect!!!

  同事离职 ,把手头的程序给我了,第二天客户说:“为什么我们导出的excel不会自己汇总啊??”

。。。。您稍等一下,我看一下哈(我怎么知道你们导出的excel为什么不会汇总啊!!)

打开程序

[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法

没什么问题,然后导出打开

[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法

这是神马?合着你导出来的全部是文本格式的了。文本格式存储的数字怎么汇总你告诉我。

看代码吧

 View Code

excel的数据格式:gvExport.Attributes.Add("style", "vnd.ms-excel.numberformat:@");

下面是常用的一些格式: 
1)文本:vnd.ms-excel.numberformat:@   
2)日期:vnd.ms-excel.numberformat:yyyy/mm/dd  
3)数字:vnd.ms-excel.numberformat:#,##0.00  
4)货币:vnd.ms-excel.numberformat:¥#,##0.00  
5)百分比:vnd.ms-excel.numberformat: #0.00% 

你这里输出的格式就是文本啊!果断的改成第三条数字类型的(哈哈,我是不是很聪明)

[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法

等等,我表头的日期怎么回事,也变成数字了,看到它还有两位小数的就挠头了(失误,失误哈)

gvExport.HeaderRow.Attributes.Add("style", "[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法vnd.ms-excel.numberformat:@");    

gvExport.Attributes.Add("style", "[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法vnd.ms-excel.numberformat:#,##0.00");
把表头改成原来的就行了,咱也不去改成时间类型了。
[转]html导出到excel数据格式不正确解决方法
html导出到excel数据格式不正确解决方法
ok!完美,perfect!!!