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


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

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

    。。。。您稍等一下,我看一下哈(我怎么知道你们导出的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% 

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

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

    gvExport.HeaderRow.Attributes.Add("style", "vnd.ms-excel.numberformat:@");    

    gvExport.Attributes.Add("style", "vnd.ms-excel.numberformat:#,##0.00");
    把表头改成原来的就行了,咱也不去改成时间类型了。
    ok!完美,perfect!!!
  • 相关阅读:
    编写可维护的JavaScript代码(部分)
    Canvas
    初识ES6
    vue.js入门上
    ASP.NET中的物理路径与虚拟路径
    慎用标签选择器
    PHP服务器负载判断
    mac下安装redis
    mac安装memcache
    MySQL定时检查是否宕机并邮件通知
  • 原文地址:https://www.cnblogs.com/zhangxin4477/p/6803616.html
Copyright © 2020-2023  润新知